-
Notifications
You must be signed in to change notification settings - Fork 1
reduce
Subhajit Sahu edited this page Dec 2, 2022
·
16 revisions
Reduce values of set to a single value.
function reduce(x, fr, acc?)
// x: a set
// fr: reduce function (acc, v, v, x)
// acc: initial value
const set = require('extra-set');
var x = new Set([1, 2, 3, 4]);
set.reduce(x, (acc, v) => acc+v);
// → 10
set.reduce(x, (acc, v) => acc+v, 100);
// → 110