This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 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=