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
something object of any type that has each(something, callback) implemented start First argument of f, for the first call of f f The 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
e object of any type that has each(e, callback) implemented f The combining function Example
F sum(e) e.reduce((+))