query
On this page

foldl'

builtins.foldl'

Primop
Docs pulled from | This Revision | 2 days ago

Takes 3 arguments

op, nul, list


Reduce a list by applying a binary operator, from left to right, e.g. foldl' op nul [x0 x1 x2 ...] = op (op (op nul x0) x1) x2) ....

For example, foldl' (acc: elem: acc + elem) 0 [1 2 3] evaluates to 6 and foldl' (acc: elem: { "${elem}" = elem; } // acc) {} ["a" "b"] evaluates to { a = "a"; b = "b"; }.

The first argument of op is the accumulator whereas the second argument is the current element being processed. The return value of each application of op is evaluated immediately, even for intermediate values.

This function is not defined in a .nix file. It is likely a builtins function or an alias of a builtins function. builtins functions are predefined functions provided by Nix.

Noogle detected

Detected Type
foldl' :: (a -> b -> a) -> a -> [b] -> a

Implementation

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