AtomQ¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
AtomQ[expr]
gives True if expr is an atomic object (Integer, Real, BigInt, Rational, Complex, Symbol, or String), and False if expr is a compound expression of the form head[...].
Examples (16)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (4)¶
In[1]:= StringQ["AbC"]
Out[1]= True
In[2]:= StringQ[""]
Out[2]= True
In[3]:= StringQ[123]
Out[3]= False
In[4]:= StringQ[] StringQ::argx: StringQ called with 0 arguments; 1 argument is expected.
Scope (6)¶
Overflows to +inf
MPFR, not machine
Exact Gaussian integer
Applications (6)¶
Integers are atoms
So is a bare symbol
A Rational is treated as atomic
And so is a Complex
A Plus has parts, so it is not an atom
A list is a List expression, not an atom
Implementation notes¶
builtin_atomq (src/core.c) returns True for any non-EXPR_FUNCTION node (integers, reals, bigints, symbols, strings) and for the two function heads Mathilda treats as atomic, Rational and Complex; every other EXPR_FUNCTION yields False.
Attributes: Protected.
References¶
See also: NumberQ, IntegerQ, StringQ, MachineNumberQ, Complex, ExactNumberQ
- Source:
src/core.c - Specification:
docs/spec/builtins/expression-information.md - Tests:
tests/test_assoc_atomicity.c - Tests:
tests/test_core.c - Tests:
tests/test_packed_list.c
Notes & additional examples¶
Notes¶
AtomQ[e] is True exactly for the expressions with no subparts: integers, bigints,
reals, symbols and strings, plus the two compound heads Mathilda treats as atomic,
Rational and Complex. Every other f[...] is False.
AtomQ is the complement of "has a head you can take Parts of". It never returns
unevaluated ā the answer is a structural property of the already-evaluated argument.