Finding unique elements of a list

Thomas Johnsson XA (LN/EAB) thomas.xa.johnsson@REDACTED
Tue Dec 7 10:36:12 CET 2004


Luke Gorrie writes:
> I've always liked this one that Magnus Fröberg showed me years ago:
> 
>   remove_dups([])    -> [];
>   remove_dups([H|T]) -> [H | [X || X <- T, X /= H]].

This is wrong, you probably mean

   remove_dups([])    -> [];
   remove_dups([H|T]) -> [H | [X || X <- remove_dups(T), X /= H]].

-- Thomas



More information about the erlang-questions mailing list