Mathematica 9 is now available

Depth

Usage

Depth[expr]等于用以确定 expr的任意部分所必需的指标的最大值加 1 .


Notes

• 原始对象的深度为 1. • Depth的计算不把表达式的头包含在内.
• 参见Mathematica全书: 2.1.7节.
• 同时参见: TensorRank, Level, LeafCount, Length, Nest.
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]:=  



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.