Depth

Depth[expr]

gives the maximum number of indices needed to specify any part of expr, plus 1.

Details and Options

  • Raw objects have depth 1.
  • The computation of Depth does not include heads of expressions.
  • Depth treats SparseArray objects just like the corresponding ordinary lists.

Examples

open allclose all

Basic Examples  (3)

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 of an Association:

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

Depth of a nested Association:

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

Scope  (3)

Generalizations & Extensions  (1)

Applications  (2)

Properties & Relations  (2)

Possible Issues  (2)

See Also

ArrayDepth  Level  LeafCount  Length  Nest

Tutorials

Introduced in 1988
(1.0)
| Updated in 2003
(5.0)