Skip to content
Subhajit Sahu edited this page Dec 28, 2022 · 15 revisions

Reduce values of entries to a single value.

Similar: map, reduce, filter, filterAt, reject, rejectAt.


function reduce(x, fr, acc?)
// x:   lists
// fr:  reduce function (acc, v, k, x)
// acc: initial value
const xlists = require('extra-lists');

var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
xlists.reduce(x, (acc, v) => acc+v);
// → 10

xlists.reduce(x, (acc, v) => acc+v, 100);
// → 110


References

Clone this wiki locally