Depth
Usage
•Depth[expr]等于用以确定 expr的任意部分所必需的指标的最大值加 1 .
Notes
• 原始对象的深度为 1.
• Depth的计算不把表达式的头包含在内.
Further Examples
The depth of an expression is one more than the level of its most deeply nested atom.
In[1]:=
|
Out[1]=
|
This is the same as the number of levels in the expression as shown by TreeForm.
In[2]:=
|
Out[2]//TreeForm=
|
Instead of counting brackets or levels, we can calculate the depth. We start by replacing all the atoms with the same symbol, say xx.
In[3]:=
|
Out[3]=
|
Now we can easily find the positions of all the atoms in the original expression.
In[4]:=
|
Out[4]=
|
The depth is more than the maximum number of indices needed to specify those positions.
In[5]:=
|
Out[5]=
|
We clear the definition.
In[6]:=
|
|