query
On this page

all

builtins.all

Primop
Docs pulled from | This Revision | about 23 hours ago


Nixpkgs manual

Returns true if function pred returns true for all elements of list.

Inputs

pred

Predicate

list

Input list

Type

all :: (a -> Bool) -> [a] -> Bool

Examples

lib.lists.all usage example

all (x: x < 3) [ 1 2 ]
=> true
all (x: x < 3) [ 1 2 3 ]
=> false
(lib.lists.all)

Nix manual

Takes 2 arguments

pred, list

Return true if the function pred returns true for all elements of list, and false otherwise.

Time Complexity

O(n * T_f) where:

  • n = list length
  • T_f = predicate evaluation time

returns early when pred returns false

Noogle detected

Aliases

Implementation

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

src/libexpr/primops.cc:4081

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