### Basic Examples

Basic Examples

Check if the elements of the second list are all contained in the first list:

In[]:=

True

Out[]=

Check if the elements of the second list are all contained in the first list:

In[]:=

False

Out[]=

### Scope

Scope

Make a function that checks if a list has 1 one, 2 twos, and 1 three:

operator=ContainsAll[{1,2,2,3}]

In[]:=

ContainsAll[{1,2,2,3}]

Out[]=

Apply to a bunch of lists:

Tally[operator/@RandomInteger[10,{1000,5}]]

In[]:=

{{False,965},{True,35}}

Out[]=

### Properties and Relations

Properties and Relations

Elements of and can be lists themselves:

e

1

e

2

In[]:=

True

Out[]=

There are not enough c’s in the first list:

In[]:=

False

Out[]=

Check the same but without considering the multiplicities:

ContainsAll[{a,b,c,c,c,c},{c,a,c,c,c,c,b}]

In[]:=

True

Out[]=

If is empty and non-empty the answer is always false:

e

1

e

2

In[]:=

False

Out[]=

If is empty the answer is always true:

e

2

In[]:=

True

Out[]=

If and are empty the answer is true:

e

1

e

2

In[]:=

True

Out[]=

### Neat Examples

Neat Examples

What are the chances that two randomly generated lists of length 10 overlap exactly:

results=Table[RandomInteger[3,10],RandomInteger[3,10]],{10000};ResourceFunction["Proportions"][results]//N

In[]:=

False0.9905,True0.0095

Out[]=