query
On this page

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
(lib.lists.any)

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 = list length
  • T_pred = pred call evaluation time

returns early when pred returns true

Noogle detected

Aliases

Implementation

This function is implemented in c++ and is part of the native nix runtime.

src/libexpr/primops.cc:4057

static void prim_any(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
    anyOrAll(true, state, pos, args, v);
}