---
title: "Sequence"
language: "en"
type: "Symbol"
summary: "Sequence[expr1, expr2, ...] represents a sequence of arguments to be spliced automatically into any function."
keywords: 
- removing sublists
- runs of arguments
- splicing
- sublists
- unpack
- headless lists
- values
- exprseq
- 
canonical_url: "https://reference.wolfram.com/language/ref/Sequence.html"
source: "Wolfram Language Documentation"
related_functions: 
  - 
    title: "FlattenAt"
    link: "https://reference.wolfram.com/language/ref/FlattenAt.en.md"
  - 
    title: "BlankSequence"
    link: "https://reference.wolfram.com/language/ref/BlankSequence.en.md"
  - 
    title: "SlotSequence"
    link: "https://reference.wolfram.com/language/ref/SlotSequence.en.md"
  - 
    title: "PatternSequence"
    link: "https://reference.wolfram.com/language/ref/PatternSequence.en.md"
  - 
    title: "List"
    link: "https://reference.wolfram.com/language/ref/List.en.md"
  - 
    title: "Listable"
    link: "https://reference.wolfram.com/language/ref/Listable.en.md"
  - 
    title: "SequenceHold"
    link: "https://reference.wolfram.com/language/ref/SequenceHold.en.md"
  - 
    title: "Splice"
    link: "https://reference.wolfram.com/language/ref/Splice.en.md"
  - 
    title: "Nothing"
    link: "https://reference.wolfram.com/language/ref/Nothing.en.md"
related_tutorials: 
  - 
    title: "Sequences"
    link: "https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#32145"
---
# Sequence

Sequence[expr1, expr2, …] represents a sequence of arguments to be spliced automatically into any function.

## Details

* ``Sequence`` objects will automatically be flattened out in all functions except those with attribute ``SequenceHold`` or ``HoldAllComplete``.

* Assignment and replacement functions have attribute ``SequenceHold``.

---

## Examples (12)

### Basic Examples (1)

``Sequence`` is automatically spliced in:

```wl
In[1]:= f[a, Sequence[b, c], d]

Out[1]= f[a, b, c, d]
```

### Scope (2)

Replace with a sequence that is automatically spliced in:

```wl
In[1]:= {u, u, u} /. u -> Sequence[a, b, c]

Out[1]= {a, b, c, a, b, c, a, b, c}
```

---

```wl
In[1]:= u = Sequence[a, b, c]

Out[1]= Sequence[a, b, c]

In[2]:= {u, u, u}

Out[2]= {a, b, c, a, b, c, a, b, c}
```

### Applications (2)

Completely flatten out all lists in the argument to a function:

```wl
In[1]:= f[{{a, b}, {c, d}, {a}}] /. List -> Sequence

Out[1]= f[a, b, c, d, a]
```

---

Conditionally add an element to a list by using ``Apply`` to delay the ``Sequence`` until evaluation:

```wl
In[1]:= myOpts[func_, target_] := {PlotStyle -> Thick, If[func === target, Filling -> 0, Sequence@@{}]}

In[2]:= myOpts[x ^ 2, x ^ 2]

Out[2]= {PlotStyle -> Thickness[Large], Filling -> 0}

In[3]:= myOpts[3x, x ^ 2]

Out[3]= {PlotStyle -> Thickness[Large]}
```

### Properties & Relations (5)

A sequence of arguments matched by ``__`` is treated as a ``Sequence`` object:

```wl
In[1]:= f[a, b, c] /. f[x__] -> x

Out[1]= Sequence[a, b, c]
```

---

``##`` represents sequences of arguments by ``Sequence`` objects:

```wl
In[1]:= ##&[a, b, c]

Out[1]= Sequence[a, b, c]
```

---

A sequence with one argument acts like ``Identity`` :

```wl
In[1]:= {a, Sequence[b], c, Identity[d]}

Out[1]= {a, b, c, d}
```

---

Functions that are ``HoldAllComplete`` do not automatically splice in ``Sequence`` objects:

```wl
In[1]:= HoldComplete[Sequence[]]

Out[1]= HoldComplete[Sequence[]]
```

Functions that have attribute ``HoldAll`` but not ``SequenceHold`` do automatically splice:

```wl
In[2]:= Hold[Sequence[]]

Out[2]= Hold[]

In[3]:= Hold//Attributes

Out[3]= {HoldAll, Protected}
```

---

An empty ``Sequence[]`` will evaporate inside any head except those with special attributes:

```wl
In[1]:= {Sequence[], a}

Out[1]= {a}

In[2]:= f[Sequence[], a]

Out[2]= f[a]
```

``Nothing`` will only disappear inside lists:

```wl
In[3]:= {Nothing, a}

Out[3]= {a}

In[4]:= f[Nothing, a]

Out[4]= f[Nothing, a]
```

### Possible Issues (2)

Most Wolfram Language functions automatically splice in ``Sequence`` objects:

```wl
In[1]:= Head[Sequence[a, b]]
```

Head::argx: Head called with 2 arguments; 1 argument is expected.

```wl
Out[1]= Head[a, b]
```

---

Assignment and replacement functions have the attribute ``SequenceHold`` :

```wl
In[1]:= u -> Sequence[a, b]

Out[1]= u -> Sequence[a, b]
```

## See Also

* [`FlattenAt`](https://reference.wolfram.com/language/ref/FlattenAt.en.md)
* [`BlankSequence`](https://reference.wolfram.com/language/ref/BlankSequence.en.md)
* [`SlotSequence`](https://reference.wolfram.com/language/ref/SlotSequence.en.md)
* [`PatternSequence`](https://reference.wolfram.com/language/ref/PatternSequence.en.md)
* [`List`](https://reference.wolfram.com/language/ref/List.en.md)
* [`Listable`](https://reference.wolfram.com/language/ref/Listable.en.md)
* [`SequenceHold`](https://reference.wolfram.com/language/ref/SequenceHold.en.md)
* [`Splice`](https://reference.wolfram.com/language/ref/Splice.en.md)
* [`Nothing`](https://reference.wolfram.com/language/ref/Nothing.en.md)

## Tech Notes

* [Sequences](https://reference.wolfram.com/language/tutorial/FunctionalOperations.en.md#32145)

## History

* Introduced in 1996 (3.0)