SymmetricDifference
SymmetricDifference[list1,list2,…]
gives the symmetric difference of the lists listi.
Details and Options
- SymmetricDifference[list1,list2] gives the sorted list of elements that are in list1 or list2 but not in both.
- SymmetricDifference[list1,list2,…] gives the sorted list of elements that appear in an odd number of the listi.
- The listi must have the same head, but it need not be List.
- SymmetricDifference[list1,list2,…,SameTesttest] applies test to each pair of elements in the listi to determine whether they should be considered the same.
Examples
open allclose allBasic Examples (2)
Options (1)
SameTest (1)
By default, SymmetricDifference performs SameQ comparisons:
Compare numbers by numerical value with Equal:
Properties & Relations (6)
SymmetricDifference[] returns {}:
SymmetricDifference[list,{}] returns list:
SymmetricDifference[l1,l2] returns the same elements as SymmetricDifference[l2,l1]:
SymmetricDifference[l1,l2] is equivalent to Union[Complement[l1,l2],Complement[l2,l1]]:
SymmetricDifference[l1,l2] is equivalent to Complement[Union[l1,l2],Intersection[l1,l2]]:
SymmetricDifference[l1,l2,…] returns the elements that appear in an odd number of lists:
UniqueElements[{l1,l2,…}] returns the elements that appear only in one of the lists:
Text
Wolfram Research (2022), SymmetricDifference, Wolfram Language function, https://reference.wolfram.com/language/ref/SymmetricDifference.html.
CMS
Wolfram Language. 2022. "SymmetricDifference." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SymmetricDifference.html.
APA
Wolfram Language. (2022). SymmetricDifference. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SymmetricDifference.html