Finding unique elements of a lis

James Hague jamesh@REDACTED
Wed Dec 1 20:21:02 CET 2004


Ulf Wiger wrote:

>u2(L) ->
>    T = ets:new(temp,[set]),
>    L1 = lists:filter(
>        fun(X) -> ets:insert_new(T, {X,1}) end, L),
>    ets:delete(T),
>    L1.

Oooh, that's pretty.  My implementation did essentially the same thing, but
I didn't use filter.  I suggest this function get added to stdlib as
lists:unique/1.

James



More information about the erlang-questions mailing list