This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / The Mathematica Book / Principles of Mathematica / Functional Operations /

2.2.11 Sequences

The function Flatten allows you to explicitly flatten out all sublists.

In[1]:= Flatten[{a, {b, c}, {d, e}}]


FlattenAt lets you specify at what positions you want sublists flattened.

In[2]:= FlattenAt[{a, {b, c}, {d, e}}, 2]


Sequence objects automatically get spliced in, and do not require any explicit flattening.

In[3]:= {a, Sequence[b, c], Sequence[d, e]}


Representing sequences of arguments in functions.

Sequence works in any function.

In[4]:= f[Sequence[a, b], c]


This includes functions with special input forms.

In[5]:= a == Sequence[b, c]


Here is a common way that Sequence is used.

In[6]:= {a, b, f[x, y], g[w], f[z, y]} /. f->Sequence