symmetricDifference - nodef/extra-lists GitHub Wiki

Obtain entries not present in both lists.

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

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

var x = ['a', 'b', 'c', 'd'], [1, 2, 3, 4](/nodef/extra-lists/wiki/'a',-'b',-'c',-'d'],-[1,-2,-3,-4);
var y = ['c', 'd', 'e', 'f'], [30, 40, 50, 60](/nodef/extra-lists/wiki/'c',-'d',-'e',-'f'],-[30,-40,-50,-60);
xlists.symmetricDifference(x, y).map(c => [...c]);
// → [ [ 'a', 'b', 'e', 'f' ], [ 1, 2, 50, 60 ] ]

var y = ['d', 'e', 'f'], [40, 50, 60](/nodef/extra-lists/wiki/'d',-'e',-'f'],-[40,-50,-60);
xlists.symmetricDifference(x, y).map(c => [...c]);
// → [ [ 'a', 'b', 'c', 'e', 'f' ], [ 1, 2, 3, 50, 60 ] ]

References