In addition to a list and an anonymous function,fold also accepts an initial value.
Example:
1 [ 2 3 ] [ + ] fold # evaluates to `6`
It would be simpler to drop the first argument:
[ 2 3 ] [ + ] fold # evaluates to `5`
If an initial value is needed, it can be easily added to the list:
[ 2 3 ] 1 prepend [ + ] fold # evaluates to `6`
In addition to a list and an anonymous function,
foldalso accepts an initial value.Example:
It would be simpler to drop the first argument:
If an initial value is needed, it can be easily added to the list: