For Bimap is there anything like Data.Map.insertWithKey ?
Stuart Cook wrote:
On Sat, Feb 9, 2008 at 7:36 AM, Dan Weston <[EMAIL PROTECTED]> wrote:
If order is important, the new bijective Data.Bimap class
http://code.haskell.org/~scook0/haddock/bimap/Data-Bimap.html
may be your best bet (I haven't yet tried it myself).
Let me try:
nub :: (Ord a) => [a] -> [a]
nub = map snd . Data.Bimap.toAscList . Data.Bimap.fromList . reverse
. zip [1..]
> nub "hello, world!"
"helo, wrd!"
Without the call to (reverse), this would still be an order-preserving
nub, except that it would preserve the relative order of the *last*
occurrence of each element. Actually, this makes me wonder whether
fromList's behaviour should be changed, and whether I should add a
"non-clobbering" variant of insert.
Stuart
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe