Flatten
Usage
• Flatten[list]压平嵌套列表。
• Flatten[list]压平n层结构。
• Flatten[list, n, h]压平有头h的子表达式。
Notes
• Flatten 有效的删除内部括号,拆开列表, • Flatten[list, n]有效地压平list中的顶层n次。 • Flatten[f[e, ... ]] 压平头为f的子表达式。
Further Examples
The second command only flattens out sublists at the first level.
In[1]:=
|
Out[1]=
|
In[2]:=
|
Out[2]=
|
This removes nested occurrences of the function g.
In[3]:=
|
Out[3]=
|
In[4]:=
|
Out[4]=
|
You can use Flatten to splice sequences of elements into lists or other expressions.
In[5]:=
|
Out[5]=
|
|