Version: v0.6.0 - Beta.  We welcome contributors & feedback.  THanks!

List.reduce

reduce($callbackFunction, $initial = '')

Description

Reduce the List to a single value, by applying a callback function to each item.

The callback receives 2 arguments:

Returns the final, singular value.

(This example uses the F shortcut for function.)

$fnSum = F ($total, $num) { return $total + $num };

[3, 6, 9, 12].reduce($fnSum);
//= 30

See Also