WOLFRAM

Copy to clipboard.
AtomQ[expr]

yields True if expr is an expression which cannot be divided into subexpressions, and yields False otherwise.

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 all

Basic Examples  (1)Summary of the most common use cases

Test if an expression cannot be subdivided:

Out[1]=1
Out[2]=2

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

Out[3]=3

This is a number that is an atom:

Out[4]=4

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

Strings are not subdividable:

Out[1]=1

Symbols are not subdividable:

Out[1]=1

Numbers are not subdividable:

Out[1]=1

Rational numbers appear to have a compound structure:

As numbers, they are not subdividable:

Out[2]=2

The parts can be accessed through Numerator and Denominator:

Out[3]=3

Complex numbers appear to have a compound structure:

As numbers, they are not subdividable:

Out[2]=2

The parts can be accessed through Re and Im:

Out[3]=3

SparseArray objects are atomic raw objects:

Out[1]=1
Out[2]=2

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

Out[3]=3
Out[4]=4
Out[5]=5

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

Out[7]=7

Applications  (2)Sample problems that can be solved with this function

Find the number of unsubdividable leaves in an expression:

A deeply nested expression:

Out[2]=2
Out[3]=3

This is equivalent to LeafCount:

Out[4]=4

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

Out[5]=5

This corresponds to the dangling leaves you see with TreeForm:

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

Out[2]=2
Out[3]=3

Depth gives the maximum depth plus 1:

Out[4]=4

Properties & Relations  (1)Properties of the function, and connections to other functions

Map[f,expr,{-1}] generally maps f on atoms in expr:

Out[1]=1

This is equivalent to the following recursive function:

Out[4]=4
Wolfram Research (1988), AtomQ, Wolfram Language function, https://reference.wolfram.com/language/ref/AtomQ.html (updated 2003).
Copy to clipboard.
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).

Copy to clipboard.
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.

Copy to clipboard.
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

Copy to clipboard.
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 ]}

Copy to clipboard.
@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 ]}

Copy to clipboard.
@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 ]}