8000 accumulate · nodef/extra-iterable Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

accumulate

Subhajit Sahu ed 8000 ited 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]


References

Clone this wiki locally
0