* A function `elem' to check whether a list contains a specific

element.

svn path=/nixpkgs/trunk/; revision=7577
This commit is contained in:
Eelco Dolstra 2007-01-08 22:49:26 +00:00
parent 735bad8c32
commit b0950cab80

View File

@ -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: