okay, this is probably going to be in the prelude, but: is there a standard library function for finding the unique elements in a list? my (re)implementation, for clarification, is:
has :: (Eq a) => [a] -> a -> Bool
has [] _ = False
has (x:xs) a
| x == a = True
| otherwise = has xs a
unique :: (Eq a) => [a] -> [a]
unique [] = []
unique (x:xs)
| has xs x = unique xs
| otherwise = x : unique xs
has
is also standard; it's justflip elem
. – Nefrubyr Jun 23 '10 at 8:19has xs = (`elem` xs)
. – yatima2975 Jun 23 '10 at 9:08elem
as infix? – dopatraman Jun 9 '16 at 2:07elem
has typeEq a => a -> [a] -> Bool
so using it as an infix operation section makesxs
the second argument.(`elem` xs)
is desugared to(\x -> elem x xs)
which is what we want here! – yatima2975 Jun 10 '16 at 9:26