-
Notifications
You must be signed in to change notification settings - Fork 5
isUnique
Subhajit Sahu edited this page May 3, 2023
·
22 revisions
Examine if there are no duplicate values.
Similar: isUnique, isDisjoint, intersection.
function isUnique(x, fc, fm)
// x: an array
// fc: compare function (a, b)
// fm: map function (v, i, x)
⏱️ Compare function ⇒ O(n²).
const xarray = require('extra-array');
var x = [1, 2, -1, -2];
xarray.isUnique(x);
// → true
xarray.isUnique(x, (a, b) => Math.abs(a) - Math.abs(b));
// → false
xarray.isUnique(x, null, v => Math.abs(v));
// → false