Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Similar to ContainsAll but taking the multiplicities into consideration
ResourceFunction["ContainsAllMultiplicities"][e1,e2] yields True if e1 contains all of the elements of e2 taking into account multiplicities. | |
ResourceFunction["ContainsAllMultiplicities"][e2] is an operator form that yields True when the object to which it is applied contains all of the elements of e2. |
Check if the elements of the second list are all contained in the first list:
| In[1]:= |
| Out[1]= |
Check if the elements of the second list are all contained in the first list:
| In[2]:= |
| Out[2]= |
Make a function that checks if a list has one 1, two 2s and one 3:
| In[3]:= |
| Out[3]= |
Apply to a bunch of lists:
| In[4]:= |
| Out[4]= |
Elements of e1 and e2 can be lists themselves:
| In[5]:= |
| Out[5]= |
There are not enough c’s in the first list:
| In[6]:= |
| Out[6]= |
Check the same but without considering the multiplicities:
| In[7]:= |
| Out[7]= |
If e1 is empty and e2 is non-empty, the answer is always False:
| In[8]:= |
| Out[8]= |
If e2 is empty, the answer is always True:
| In[9]:= |
| Out[9]= |
If e1 and e2 are both empty, the answer is True:
| In[10]:= |
| Out[10]= |
What are the chances that two randomly generated lists of length 10 overlap exactly? Use ContainsAllMultiplicities in conjunction with the resource function Proportions to find out:
| In[11]:= | ![]() |
| Out[12]= |
This work is licensed under a Creative Commons Attribution 4.0 International License