-
Notifications
You must be signed in to change notification settings - Fork 1
accumulate
Subhajit Sahu edited this page May 17, 2020
·
15 revisions
Produces accumulating values. 🏃 📼 📦 🌔 📒
iterable.accumulate(x, fn, [acc]);
// x: an iterable
// fn: reduce function (acc, v, i, x)
// acc: initial value
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4];
[...iterable.accumulate(x, (acc, v) => acc+v)];
// [ 1, 3, 6, 10 ]
[...iterable.accumulate(x, (acc, v) => acc+v, 100)];
// [ 101, 103, 106, 110 ]