difference - nodef/extra-lists GitHub Wiki

Obtain entries not present in another lists.

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

function difference(x, y)
// x: lists
// y: another lists
const xlists = require('extra-lists');

var x = ['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5](/nodef/extra-lists/wiki/'a',-'b',-'c',-'d',-'e'],-[1,-2,-3,-4,-5);
var y = ['b', 'd'], [2, 4](/nodef/extra-lists/wiki/'b',-'d'],-[2,-4);
xlists.difference(x, y).map(c => [...c]);
// → [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]

var y = ['b', 'd'], [-2, -4](/nodef/extra-lists/wiki/'b',-'d'],-[-2,--4);
xlists.difference(x, y).map(c => [...c]);
// → [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]

References