query
On this page

foldr

lib.lists.foldr

Docs pulled from | This Revision | 21 minutes ago


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

Inputs

op

1. Function argument

nul

2. Function argument

list

3. Function argument

Type

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

Examples

lib.lists.foldr usage 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"

Noogle also knows

Aliases