Add unique list function

It removes duplicate elements from a list.
This commit is contained in:
Ricardo M. Correia 2014-11-12 21:36:26 +01:00
parent 3b0fa60a98
commit 1fea5866ae

View File

@ -223,4 +223,14 @@ rec {
crossLists = f: foldl (fs: args: concatMap (f: map f args) fs) [f];
# Remove duplicate elements from the list
unique = list:
if list == [] then
[]
else
let
x = head list;
xs = unique (drop 1 list);
in [x] ++ remove x xs;
}