query
On this page

foldr

lib.lists.foldr



“right fold” a binary function op between successive elements of list with nul as the starting value, i.e., foldr op nul [x_1 x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul)).

Example

concat = foldr (a: b: a + b) "z"
concat [ "a" "b" "c" ]
=> "abcz"
# different types
strange = foldr (int: str: toString (int + 1) + str) "a"
strange [ 1 2 3 4 ]
=> "2345a"

Type

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

Arguments

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

Noogle also knows

Aliases