any
builtins.any
Primop
Docs pulled from | This Revision | 18 minutes ago
Nixpkgs manual
Returns true if function pred returns true for at least one
element of list.
Inputs
pred-
Predicate
list-
Input list
Type
any :: (a -> Bool) -> [a] -> Bool
Examples
lib.lists.any usage example
any isString [ 1 "a" { } ]
=> true
any isString [ 1 { } ]
=> false
Nix manual
Takes 2 arguments
pred, list
Return true if the function pred returns true for at least one
element of list, and false otherwise.
Time Complexity
O(n * T_pred) where:
- n =
listlength - T_pred =
predcall evaluation time
returns early when pred returns true
Noogle detected
Implementation
This function is implemented in c++ and is part of the native nix runtime.
static void prim_any(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
anyOrAll(true, state, pos, args, v);
}