diff options
Diffstat (limited to 'lib/lists.nix')
-rw-r--r-- | lib/lists.nix | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/lists.nix b/lib/lists.nix index f424946c72c..e469f3ef265 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -1,9 +1,9 @@ # General list operations. { lib }: -with lib.trivial; let inherit (lib.strings) toInt; + inherit (lib.trivial) compare min; in rec { @@ -241,7 +241,7 @@ rec { /* Return a singleton list or an empty list, depending on a boolean value. Useful when building lists with optional elements - (e.g. `++ optional (system == "i686-linux") flashplayer'). + (e.g. `++ optional (system == "i686-linux") firefox'). Type: optional :: bool -> a -> [a] @@ -629,7 +629,9 @@ rec { crossLists (x:y: "${toString x}${toString y}") [[1 2] [3 4]] => [ "13" "14" "23" "24" ] */ - crossLists = f: foldl (fs: args: concatMap (f: map f args) fs) [f]; + crossLists = builtins.trace + "lib.crossLists is deprecated, use lib.cartesianProductOfSets instead" + (f: foldl (fs: args: concatMap (f: map f args) fs) [f]); /* Remove duplicate elements from the list. O(n^2) complexity. @@ -640,13 +642,7 @@ rec { unique [ 3 2 3 4 ] => [ 3 2 4 ] */ - unique = list: - if list == [] then - [] - else - let - x = head list; - in [x] ++ unique (remove x list); + unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) []; /* Intersects list 'e' and another list. O(nm) complexity. |