query
On this page

foldl

lib.lists.foldl



“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).

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"

Type

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

Arguments

  • [op]
  • [nul]
  • [list]

Noogle also knows

Aliases