Created
September 28, 2011 00:26
-
-
Save pragmaticobjects/1246662 to your computer and use it in GitHub Desktop.
Remove duplicates in a list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -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