Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Lists and Matrices / List Testing  /
Depth

  • Depth[ expr ] gives the maximum number of indices needed to specify any part of expr, plus one.
  • Raw objects have depth 1.
  • The computation of Depth does not include heads of expressions.
  • See the Mathematica book: Section 2.1.7.
  • See also: TensorRank, Level, LeafCount, Length, Nest.

    Further Examples

    You can think of expressions as having a depth which is equal to the maximum number of levels shown by TreeForm. In general, -n in an expression is defined to consist of all subexpressions whose depth is n.

    In[1]:=

    Out[1]=

    In[2]:=

    Out[2]=

    In[3]:=

    Out[3]//TreeForm=



    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.