
8 Feb
2008
8 Feb
'08
10:35 p.m.
On Sat, Feb 9, 2008 at 7:36 AM, Dan Weston
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