Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Memory Usage  /
LeafCount

  • LeafCount[ expr ] gives the total number of indivisible subexpressions in expr.
  • LeafCount gives a measure of the total "size" of an expression.
  • LeafCount counts the number of subexpressions in expr which correspond to "leaves" on the expression tree.
  • Example: LeafCount[1 + a + b^2].
  • See the Mathematica book: Section 2.13.4.
  • See also: ByteCount, Length, Depth, AtomQ.

    Further Examples

    Here are two cases where it helps to see the internal representation.

    In[1]:=

    Out[1]=

    In[2]:=

    Out[2]//FullForm=

    In[3]:=

    Out[3]=

    In[4]:=

    Out[4]//FullForm=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.