query
On this page

foldl

lib.lists.foldl

Docs pulled from | This Revision | about 12 hours ago


“left fold”, like foldr, but from the left:

foldl op nul [x_1 x_2 ... x_n] == op (... (op (op nul x_1) x_2) ... x_n).

Inputs

op

1. Function argument

nul

2. Function argument

list

3. Function argument

Type

foldl :: (b -> a -> b) -> b -> [a] -> b

Examples

lib.lists.foldl usage example

lconcat = foldl (a: b: a + b) "z"
lconcat [ "a" "b" "c" ]
=> "zabc"
# different types
lstrange = foldl (str: int: str + toString (int + 1)) "a"
lstrange [ 1 2 3 4 ]
=> "a2345"

Noogle also knows

Aliases