unique
lib.lists.unique
Docs pulled from | This Revision | 14 minutes ago
Remove duplicate elements from the list
. O(n^2) complexity.
Inputs
list
-
Input list
Type
unique :: [a] -> [a]
Examples
lib.lists.unique
usage example
unique [ 3 2 3 4 ]
=> [ 3 2 4 ]
Noogle detected
Implementation
This function is implemented in c++ and is part of the native nix runtime.
Implementation
The following is the current implementation of this function.
unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];