reduce multimethod

Methods

reduce(something:Eachable1, start:Any, f:Fun) Source: stdlib.ngs:1290
Combine items to a single value using the supplied binary function First f is applied to start and the first element of something then on each step f is applied to previous result and next element of something.

Parameters

somethingobject of any type that has each(something, callback) implemented
startFirst argument of f, for the first call of f
fThe combining function

Example

F sum(something) something.reduce(0, (+))
reduce(e:Eachable1, f:Fun) Source: stdlib.ngs:1308
Combine items to a single value using the supplied binary function First f is applied to the first two elements of e then on each step f is applied to previous result and next element of e. Throws EmptyEachableFail if e has no elements. If e has only one element, that element is returned.

Parameters

eobject of any type that has each(e, callback) implemented
fThe combining function

Example

F sum(e) e.reduce((+))