Skip to content

intersection

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

Obtain entries present in both ilists.

Similar: union, intersection, difference, symmetricDifference, isDisjoint.


function intersection(x, y, fc)
// x:  ilists
// y:  another ilists
// fc: combine function (a, b)
const xilists = require('extra-ilists');

var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
var y = [['b', 'c', 'e'], [20, 30, 50]];
xilists.intersection(x, y).map(c => [...c]);
// → [ [ 'b', 'c' ], [ 2, 3 ] ]

xilists.intersection(x, y, (a, b) => b).map(c => [...c]);
// → [ [ 'b', 'c' ], [ 20, 30 ] ]


References

Clone this wiki locally