diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index da279302306..0980a464704 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -61,6 +61,10 @@ rec { fold (x: y: if pred x then [x] ++ y else y) [] list; + # Return true if `list' has an element `x': + elem = x: list: fold (a: bs: x == a || bs) false list; + + # Find the sole element in the list matching the specified # predicate, or returns the default value. findSingle = pred: default: list: