Version: v0.7.1 - Beta.  We welcome contributors & feedback.

List.reduce

reduce($callbackFunction, $initial = '') -> any

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.

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

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

See Also