Function Repository Resource:

# UnsortedComplement

Delete the elements of some lists from a list x without changing either the order of x or the multiplicities of its elements

Contributed by: George Beck
 ResourceFunction["UnsortedComplement"][list, del1,del2, …] deletes from list any occurrence of an element of the del1, del2, … without otherwise changing list.

## Details and Options

ResourceFunction["UnsortedComplement"] differs from Complement, which deletes but also reduces the multiplicity of each element to one and sorts.
ResourceFunction["UnsortedComplement"] accepts SameTest as an option.

## Examples

### Basic Examples

Delete specified elements from a list:

 In[1]:=
 Out[1]=

### Scope

Deleting with several lists is equivalent to deleting with their join:

 In[2]:=
 Out[2]=

### Options

Use equivalence classes based on absolute value:

 In[3]:=
 Out[3]=

This considers elements the same if they are identical modulo 3:

 In[4]:=
 Out[4]=

These are the deleted elements:

 In[5]:=
 Out[5]=

Here there is no second list, so nothing is deleted:

 In[6]:=
 Out[6]=

### Properties and Relations

Complement deletes elements, reduces remaining elements to one occurrence of each, and sorts:

 In[7]:=
 Out[7]=

UnsortedComplement only deletes elements:

 In[8]:=
 Out[8]=

Make two lists:

 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=

Union deletes duplicates and sorts:

 In[11]:=
 Out[11]=
 In[12]:=
 Out[12]=
 In[13]:=
 Out[13]=

## Requirements

Wolfram Language 11.3 (March 2018) or above