Skip to content

Instantly share code, notes, and snippets.

@sushant12
Created May 17, 2020 03:49
Show Gist options
  • Save sushant12/e859058cbd4688c9f51bf7271d5c3add to your computer and use it in GitHub Desktop.
Save sushant12/e859058cbd4688c9f51bf7271d5c3add to your computer and use it in GitHub Desktop.
-module(nub).
-export([nub/1]).
nub([]) -> [];
nub(Xs) -> nub(Xs, []).
nub([], C) -> lists:reverse(C);
nub([X | Xs], C) ->
Ret = case lists:member(X, C) of
true -> C;
false -> [X | C]
end,
nub(Xs, Ret).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment