Skip to content
Subhajit Sahu edited this page Dec 2, 2022 · 16 revisions

Reduce values of set to a single value.

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


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


References

Clone this wiki locally