Depth
Depth[expr]
returns the depth of expr
.
Attributes[Depth] := {Protected}
Simple examples
In[1]:= Depth[foo] Out[1]= 1
In[2]:= Depth[{foo}] Out[2]= 2
In[3]:= Depth[bar[foo, bar]] Out[3]= 2
In[4]:= Depth[foo[foo[]]] Out[4]= 3
In[5]:= Depth[3] Out[5]= 1
In[6]:= Depth[3.5] Out[6]= 1
In[7]:= Depth[(3)/(5)] Out[7]= 1
In[8]:= Depth[foo[{{{}}}][]] Out[8]= 2