-
Notifications
You must be signed in to change notification settings - Fork 1
accumulate
Subhajit Sahu edited this page Feb 3, 2021
·
15 revisions
Produce accumulating values.
Similar: map, filter, reject, reduce, accumulate.
function accumulate(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.accumulate(x, (acc, v) => acc+v)];
// → [1, 3, 6, 10]
[...xiterable.accumulate(x, (acc, v) => acc+v, 100)];
// → [101, 103, 106, 110]