Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Delete the elements of some lists from a list x without changing either the order of x or the multiplicities of its elements
ResourceFunction["UnsortedComplement"][list, del1,del2, …] deletes from listany occurrence of an element of the del1,del2,… without otherwise changing list. |
Deleting with several lists is equivalent to deleting with their Join:
| In[2]:= |
| Out[2]= |
| In[3]:= |
| Out[3]= |
Use equivalence classes based on absolute value:
| In[4]:= |
| Out[4]= |
This considers elements the same if they are identical modulo 3:
| In[5]:= |
| Out[5]= |
These are the deleted elements:
| In[6]:= |
| Out[6]= |
Here there is no second list, so nothing is deleted:
| In[7]:= |
| Out[7]= |
Complement deletes elements, reduces remaining elements to one occurrence of each, and sorts:
| In[8]:= |
| Out[8]= |
UnsortedComplement only deletes elements:
| In[9]:= |
| Out[9]= |
Make two lists:
| In[10]:= |
| Out[10]= |
| In[11]:= |
| Out[11]= |
Union deletes duplicates and sorts:
| In[12]:= |
| Out[12]= |
| In[13]:= |
| Out[13]= |
| In[14]:= |
| Out[14]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License