Commit 1fea5866 authored by Ricardo M. Correia's avatar Ricardo M. Correia
Browse files

Add `unique` list function

It removes duplicate elements from a list.
parent 3b0fa60a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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;

}