Skip to content

Instantly share code, notes, and snippets.

@pragmaticobjects
Created September 28, 2011 00:26
Show Gist options
  • Select an option

  • Save pragmaticobjects/1246662 to your computer and use it in GitHub Desktop.

Select an option

Save pragmaticobjects/1246662 to your computer and use it in GitHub Desktop.
Remove duplicates in a list
-module(removedup).
-export([removedup/1]).
compare(H, []) -> [H];
compare(H, [H|T]) -> [H|T];
compare(H1, [H|T]) ->
L = [H|T],
[H1|L].
removedup(L) -> removedup(L, []).
removedup([], Acc) -> Acc;
removedup([H|T], Acc) -> removedup(T, compare(H, Acc)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment