Skip to content

SameQ

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

lhs === rhs or SameQ[lhs, rhs]
    yields True if lhs and rhs are structurally identical (head-by-head,
    argument-by-argument), and False otherwise.  Numerically equal but
    distinct heads (e.g. 1 and 1.) are NOT considered same.

Examples

No verified examples yet for this function.

Implementation notes

builtin_sameq tests purely structural identity. With fewer than two arguments it returns True by convention; otherwise it compares every argument against the first with expr_eq and returns True only if all are structurally equal, False otherwise. Unlike Equal, there is no numeric coercion — 1 === 1. is False — and it never returns NULL (the result is always a definite boolean).

  • Unlike Equal, SameQ never stays symbolic and does not coerce numeric

Attributes: Protected.

Implementation status

Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

References

Notes & additional examples

Worked examples

In[1]:= a === a
Out[1]= True

In[2]:= 1 === 1.
Out[2]= False

In[3]:= f[x] === f[x]
Out[3]= True

Notes

SameQ (===) is a structural test that always returns True or False. Numerically equal but distinct heads, such as 1 (Integer) and 1. (Real), are not the same.