mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-25 20:34:52 +03:00
* A function `elem' to check whether a list contains a specific
element. svn path=/nixpkgs/trunk/; revision=7577
This commit is contained in:
parent
735bad8c32
commit
b0950cab80
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user