This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Depth

Depth[expr]
gives the maximum number of indices needed to specify any part of expr, plus 1.
  • Raw objects have depth .
  • The computation of Depth does not include heads of expressions.
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
Depth works on any expression, not just lists:
Depth does not distinguish heads:
All numbers have depth 1:
Find how deeply nested results from integrals are:
Find the depths of combinator expressions
Depth gives the length of the maximum index, plus 1:
Successive elements from NestList have larger depths:
Depth does not count depth in the head:
New in 1 | Last modified in 5