Skip to content

symmetricDifference

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

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]];
var y = [['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]];
xlists.symmetricDifference(x, y).map(c => [...c]);
// → [ [ 'a', 'b', 'c', 'e', 'f' ], [ 1, 2, 3, 50, 60 ] ]


References

Clone this wiki locally