LeafCount

LeafCount[expr]

gives the total number of indivisible subexpressions in expr.

Details

  • LeafCount gives a measure of the total "size" of an expression.
  • LeafCount counts the number of subexpressions in expr that correspond to "leaves" on the expression tree.
  • LeafCount is based on FullForm representation of expressions.
  • Numbers with heads Rational and Complex are treated as composite objects, just as in FullForm.

Examples

open all close all

Basic Examples  (1)

Find the number of "leaves" in an expression tree:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Applications  (3)

Properties & Relations  (2)

Possible Issues  (5)

Introduced in 1988
(1.0)