
Apologies. I was being lazy. Here's a stable version:
import qualified Data.HashSet as S
hashNub :: (Ord a) => [a] -> [a]
hashNub l = go S.empty l
where
go _ [] = []
go s (x:xs) = if x `S.member` s then go s xs
else x : go (S.insert x s) xs
Which, again, will probably be faster than the one using Ord, and I
can't think of any cases where I'd want the one using Ord instead. I
may just not be creative enough, though.
- Clark
On Mon, Jul 15, 2013 at 12:46 AM, Brandon Allbery
On Sun, Jul 14, 2013 at 7:54 AM, Clark Gaebel
wrote: Oops sorry I guess my point wasn't clear.
Why ord based when hashable is faster? Then there's no reason this has to be in base, it can just be a
Did the point about "stable" fly overhead?
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net