foldr ( ... list identity quot: ( ... prev elt -- ... next ) -- ... result )
Factor handbook » The language » Collections » Lists » Combinators for lists

Prev:foldl ( ... list identity quot: ( ... prev elt -- ... next ) -- ... result )
Next:lmap>array ( ... list quot: ( ... elt -- ... newelt ) -- ... array )


Vocabulary
lists

Inputs
lista list
identityan object
quota quotation with stack effect ( ... prev elt -- ... next )


Outputs
resultthe final result


Word description
Combines successive elements of the list (in a right-associative order) using a binary operation, and outputs the final result.

Definition


:: foldr
( ... list identity quot: ( ... prev elt -- ... next ) -- ... result )
list nil?
[ identity ]
[ list cdr identity quot foldr list car quot call ] if ;
inline recursive