Wolfram Computation Meets Knowledge

AllSameAs

Contributed by: Taliesin Beynon (Wolfram Research)

Check if all elements of a list are the same as a value

ResourceFunction["AllSameAs"][list,val]

yields True if all elements of list are identical to val.

Details and Options

Elements are considered identical if SameQ gives True with val.

Examples

Basic Examples

Check if all elements match a value:

In[1]:=
ResourceFunction["AllSameAs"][{1, 1, 1}, 1]
Out[1]=

If any values do not match AllSameAs gives False:

In[2]:=
ResourceFunction["AllSameAs"][{1, 2, 1}, 1]
Out[2]=

Properties and Relations

Patterns are not supported:

In[3]:=
ResourceFunction["AllSameAs"][{1, 2, 3}, _Integer]
Out[3]=

Resource History