[Haskell-cafe] Data.Map add only if not exist and return true if added

John Ky newhoggy at gmail.com
Tue Dec 9 03:11:33 EST 2008


I'm looking for a function for Data.Map that will insert a new key and value
into the map if the key doesn't already exist in the map.  When the key
already exists, I don't want the value updated in the map.  Additionally, I
want to know whether the key/value was inserted or not so that I can return
that fact as a boolean from my function.

I can't work out which function in Data.Map is suitable for this task and I
wanted to avoid two lookups.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081209/ddf248d9/attachment.htm

More information about the Haskell-Cafe mailing list