AtomQCopy to clipboard.
✖
AtomQ
Details

- You can use AtomQ in a recursive procedure to tell when you have reached the bottom of the tree corresponding to an expression.
- AtomQ gives True for symbols, numbers, strings, and other raw objects, such as sparse arrays.
- AtomQ gives True for any object whose subparts cannot be accessed using functions like Map.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Test if an expression cannot be subdivided:

https://wolfram.com/xid/0cqzylab-k2be3


https://wolfram.com/xid/0cqzylab-epzva5

Since it is not an atom, its parts can be extracted:

https://wolfram.com/xid/0cqzylab-cabb5g

This is a number that is an atom:

https://wolfram.com/xid/0cqzylab-kf3sxf

Scope (6)Survey of the scope of standard use cases

https://wolfram.com/xid/0cqzylab-1nd8i


https://wolfram.com/xid/0cqzylab-8hmg3


https://wolfram.com/xid/0cqzylab-far6y8

Rational numbers appear to have a compound structure:

https://wolfram.com/xid/0cqzylab-bsk1pa

As numbers, they are not subdividable:

https://wolfram.com/xid/0cqzylab-eg34nn

The parts can be accessed through Numerator and Denominator:

https://wolfram.com/xid/0cqzylab-e2jodr

Complex numbers appear to have a compound structure:

https://wolfram.com/xid/0cqzylab-bsc4t3

As numbers, they are not subdividable:

https://wolfram.com/xid/0cqzylab-cu8wf6

The parts can be accessed through Re and Im:

https://wolfram.com/xid/0cqzylab-f8rh1

SparseArray objects are atomic raw objects:

https://wolfram.com/xid/0cqzylab-mbixji


https://wolfram.com/xid/0cqzylab-jdun89

Commands that work with SparseArray objects typically do so on the represented array:

https://wolfram.com/xid/0cqzylab-lk00k


https://wolfram.com/xid/0cqzylab-eu6q9


https://wolfram.com/xid/0cqzylab-qxw9je

The FullForm of a SparseArray object is designed to be sufficient to reconstruct the raw object:

https://wolfram.com/xid/0cqzylab-c81bjf


https://wolfram.com/xid/0cqzylab-bgsy21

Applications (2)Sample problems that can be solved with this function
Find the number of unsubdividable leaves in an expression:

https://wolfram.com/xid/0cqzylab-2oo76

https://wolfram.com/xid/0cqzylab-savvp


https://wolfram.com/xid/0cqzylab-f9jdq0

This is equivalent to LeafCount:

https://wolfram.com/xid/0cqzylab-dzln3i

With the option Heads->False, only atoms with no branches are counted:

https://wolfram.com/xid/0cqzylab-ctagw2

This corresponds to the dangling leaves you see with TreeForm:

https://wolfram.com/xid/0cqzylab-e49qrx

Find the minimum and maximum "depth" of an expression:

https://wolfram.com/xid/0cqzylab-dj93a7

https://wolfram.com/xid/0cqzylab-fkc1k3


https://wolfram.com/xid/0cqzylab-il22ls

Depth gives the maximum depth plus 1:

https://wolfram.com/xid/0cqzylab-fsqem4

Properties & Relations (1)Properties of the function, and connections to other functions
Map[f,expr,{-1}] generally maps f on atoms in expr:

https://wolfram.com/xid/0cqzylab-bkmmbb

This is equivalent to the following recursive function:

https://wolfram.com/xid/0cqzylab-ear85r

https://wolfram.com/xid/0cqzylab-fykpeo

Wolfram Research (1988), AtomQ, Wolfram Language function, https://reference.wolfram.com/language/ref/AtomQ.html (updated 2003).
Text
Wolfram Research (1988), AtomQ, Wolfram Language function, https://reference.wolfram.com/language/ref/AtomQ.html (updated 2003).
Wolfram Research (1988), AtomQ, Wolfram Language function, https://reference.wolfram.com/language/ref/AtomQ.html (updated 2003).
CMS
Wolfram Language. 1988. "AtomQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2003. https://reference.wolfram.com/language/ref/AtomQ.html.
Wolfram Language. 1988. "AtomQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2003. https://reference.wolfram.com/language/ref/AtomQ.html.
APA
Wolfram Language. (1988). AtomQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AtomQ.html
Wolfram Language. (1988). AtomQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AtomQ.html
BibTeX
@misc{reference.wolfram_2025_atomq, author="Wolfram Research", title="{AtomQ}", year="2003", howpublished="\url{https://reference.wolfram.com/language/ref/AtomQ.html}", note=[Accessed: 26-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_atomq, organization={Wolfram Research}, title={AtomQ}, year={2003}, url={https://reference.wolfram.com/language/ref/AtomQ.html}, note=[Accessed: 26-March-2025
]}