Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Test if all arguments of an expression are identical
Test whether all expressions in a list are identically the same:
In[1]:= |
Out[1]= |
In[2]:= |
Out[2]= |
Numbers in different representations are not the same:
In[3]:= |
Out[3]= |
The argument need not be a list:
In[4]:= |
Out[4]= |
In[5]:= |
Out[5]= |
For associations, AllSameQ operates on values:
In[6]:= |
Out[6]= |
In[7]:= |
Out[7]= |
Use Unevaluated to test arguments without evaluation:
In[8]:= |
Out[8]= |
In[9]:= |
Out[9]= |
In many cases, AllSameQ[expr] is effectively equivalent to Apply[SameQ,expr]:
In[10]:= |
Out[10]= |
In[11]:= |
Out[11]= |
An exception is that AllSameQ will not evaluate held arguments:
In[12]:= |
Out[12]= |
Compare with Apply[SameQ,expr]:
In[13]:= |
Out[13]= |
AllSameQ expects nonatomic expressions:
In[14]:= |
Out[14]= |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License