Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Perform the complement operation on multisets without sorting
ResourceFunction["UnsortedMultisetComplement"][listall,list1,list2,…] gives the elements in listall that are in excess of those in all the listi maintaining the original order. |
Find the complement of a multiset with another multiset, maintaining the original order:
In[1]:= |
Out[1]= |
Find a complement of a multiset to two other multisets. First generate the multisets:
In[2]:= |
Out[2]= |
In[3]:= |
Out[3]= |
In[4]:= |
Out[4]= |
Find the complement:
In[5]:= |
Out[5]= |
Find letters in one word not present in another, maintaining the order:
In[6]:= |
Out[6]= |
Compare with the resource function UnsortedComplement:
In[7]:= |
Out[7]= |
In[8]:= |
Out[8]= |
Here is a step-by-step demonstration of what UnsortedMultisetComplement does:
In[9]:= |
Out[9]= |
We will be removing 1 p, 2 qs, 3 rs, and 4ws, starting from the back.
Remove 1 p:
In[10]:= |
Remove 2 qs:
In[11]:= |
Remove 3 rs:
In[12]:= |
Remove 4 ws:
In[13]:= |
In[14]:= |
Out[14]= |
This is what we have:
In[15]:= |
Out[15]= |
Remove characters of a short word from a long word to form a new word:
In[16]:= |
Out[16]= |
Wolfram Language 13.1 (June 2022) or above
This work is licensed under a Creative Commons Attribution 4.0 International License