-
Notifications
You must be signed in to change notification settings - Fork 1
reduce
Subhajit Sahu edited this page Feb 3, 2021
·
24 revisions
Reduce values of iterable to a single value.
Similar: map, filter, reject, reduce, accumulate.
function reduce(x, fr, acc?)
// x: an iterable
// fr: reduce function (acc, v, i, x)
// acc: initial value
const xiterable = require('extra-iterable');
var x = [1, 2, 3, 4];
xiterable.reduce(x, (acc, v) => acc+v);
// → 10
xiterable.reduce(x, (acc, v) => acc+v, 100);
// → 110