-
Notifications
You must be signed in to change notification settings - Fork 0
reduce
Subhajit Sahu edited this page Dec 28, 2022
·
15 revisions
Reduce values of entries to a single value.
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