-
Notifications
You must be signed in to change notification settings - Fork 0
hasSubset
Subhajit Sahu edited this page Dec 28, 2022
·
10 revisions
Check if lists has a subset.
Alternatives: has, hasValue, hasEntry, hasSubset, hasPath.
Similar: randomSubset, subsets, hasSubset.
function hasSubset(x, y, fc, fm)
// x: lists
// y: search subset
// fc: compare function (a, b)
// fm: map function (v, k, x)
const xlists = require('extra-lists');
var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
var y = [['b', 'd'], [2, 4]];
xlists.hasSubset(x, y);
// → true
var y = [['b', 'd'], [-2, -4]];
xlists.hasSubset(x, y);
// → false
xlists.hasSubset(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// → true
xlists.hasSubset(x, y, null, v => Math.abs(v));
// → true