 |
2.2.11 Sequences| The function Flatten allows you to explicitly flatten out all sublists. | |
In[1]:=
Flatten[{a, {b, c}, {d, e}}]
|
Out[1]=
|
|
| FlattenAt lets you specify at what positions you want sublists flattened. | |
In[2]:=
FlattenAt[{a, {b, c}, {d, e}}, 2]
|
Out[2]=
|
|
| Sequence objects automatically get spliced in, and do not require any explicit flattening. | |
In[3]:=
{a, Sequence[b, c], Sequence[d, e]}
|
Out[3]=
|
|
Sequence[ , , ... ] | a sequence of arguments that will automatically be spliced into any function |
Representing sequences of arguments in functions. | Sequence works in any function. | |
In[4]:=
f[Sequence[a, b], c]
|
Out[4]=
|
|
| This includes functions with special input forms. | |
In[5]:=
a Sequence[b, c]
|
Out[5]=
|
|
| Here is a common way that Sequence is used. | |
In[6]:=
{a, b, f[x, y], g[w], f[z, y]} /. f->Sequence
|
Out[6]=
|
|
|
|
|