Skip to content

hasSubset

Subhajit Sahu edited this page Dec 28, 2022 · 10 revisions

Check if ilists has a subset.

Alternatives: has, hasValue, hasEntry, hasSubset, hasPath.
Similar: randomSubset, subsets, hasSubset.


function hasSubset(x, y, fc, fm)
// x:  ilists
// y:  search subset
// fc: compare function (a, b)
// fm: map function (v, k, x)
const xilists = require('extra-ilists');

var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
var y = [['b', 'd'], [2, 4]];
xilists.hasSubset(x, y);
// → true

var y = [['b', 'd'], [-2, -4]];
xilists.hasSubset(x, y);
// → false

xilists.hasSubset(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// → true

xilists.hasSubset(x, y, null, v => Math.abs(v));
// → true


References

Clone this wiki locally