Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the symmetric difference of the given lists
ResourceFunction["MultisetSymmetricDifference"][L1,L2,…] gives the list of elements that occur an odd number of times in the lists L1,L2,…. |
Here is the symmetric difference of two sets:
In[1]:= |
Out[1]= |
Another example:
In[2]:= |
Out[2]= |
Like Union, Intersection, and Complement, a single list is pruned of duplicates and sorted:
In[3]:= |
Out[3]= |
Define two lists, one with a duplicated element:
In[4]:= |
The lists are equal up to duplicates, so the set symmetric difference is empty:
In[5]:= |
Out[5]= |
The element 1 occurs an odd number of times in the multiset sum of the lists:
In[6]:= |
Out[6]= |
Therefore, 1 is in the multiset difference:
In[7]:= |
Out[7]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License