Function Repository Resource:

AllSameAs

Source Notebook

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

Contributed by: Taliesin Beynon

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 (2) 

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 (1) 

Patterns are not supported:

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

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 03 December 2018

License Information