[Haskell-cafe] ordNub
Clark Gaebel
cgaebel at uwaterloo.ca
Mon Jul 15 14:43:22 CEST 2013
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 <allbery.b at gmail.com> wrote:
> On Sun, Jul 14, 2013 at 7:54 AM, Clark Gaebel <cgaebel at uwaterloo.ca> 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 at gmail.com ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
More information about the Haskell-Cafe
mailing list