-
Notifications
You must be signed in to change notification settings - Fork 1
min
Subhajit Sahu edited this page Dec 2, 2022
·
16 revisions
Find smallest value.
function min(x, fc, fm)
// x: a set
// fc: compare function (a, b)
// fm: map function (v, v, x)
const set = require('extra-set');
var x = new Set([1, 2, -3, -4]);
set.min(x);
// → -4
set.min(x, (a, b) => Math.abs(a) - Math.abs(b));
// → 1
set.min(x, null, v => Math.abs(v));
// → 1