Level
Usage
• Level[expr, levelspec] 给出由levelspec指定的层上的expr的所有子表达式的列表。
• Level[expr, levelspec, f] 应用 f 到子表达式的列表。
Notes
• Level 使用在 A.3.6节中描述的标准层规范。 • Level[expr, -1 ] 给出在 expr中所有的"原子"对象列表。 • Level 以深度优先顺序遍历表达式,因而最终的列表中的子表达式使用它们的索引按字典序排序。 • 参见 Mathematica 全书 : 节 2.1.7.
Further Examples
Here are the subexpressions of a quadratic polynomial that occur at levels , , and .
In[1]:=
|
Out[1]=
|
In[2]:=
|
Out[2]=
|
In[3]:=
|
Out[3]=
|
In[4]:=
|
Out[4]=
|
The list of the subexpressions of the polynomial that occur down to level is the union of the last three results.
In[5]:=
|
Out[5]=
|
This adds up the results.
In[6]:=
|
Out[6]=
|
In[7]:=
|
See the Further Examples for Depth and TreeForm.
|