Sequence[expr1,expr2,…]
represents a sequence of arguments to be spliced automatically into any function.
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
open all close allBasic Examples (1)
Sequence is automatically spliced in:
f[a, Sequence[b, c], d]Scope (2)
Applications (2)
Completely flatten out all lists in the argument to a function:
f[{{a, b}, {c, d}, {a}}] /. List -> SequenceConditionally add an element to a list by using Apply to delay the Sequence until evaluation:
myOpts[func_, target_] := {PlotStyle -> Thick, If[func === target, Filling -> 0, Sequence@@{}]}myOpts[x ^ 2, x ^ 2]myOpts[3x, x ^ 2]Properties & Relations (6)
A sequence of arguments matched by __ is treated as a Sequence object:
f[a, b, c] /. f[x__] -> x## represents sequences of arguments by Sequence objects:
##&[a, b, c]A sequence with one argument acts like Identity:
{a, Sequence[b], c, Identity[d]}Functions that are HoldAllComplete do not automatically splice in Sequence objects:
HoldComplete[Sequence[]]Functions that have attribute HoldAll but not SequenceHold do automatically splice:
Hold[Sequence[]]Hold//AttributesAn empty Sequence[] will evaporate inside any head except those with special attributes:
{Sequence[], a}f[Sequence[], a]Nothing will only disappear inside lists:
{Nothing, a}f[Nothing, a]Splice a sequence of elements in any expression:
u = Sequence[a, b]{u, u}f[u, u]Splice[…] will only splice the elements inside lists by default:
u = Splice[{a, b}]{u, u}f[u, u]Specify the head into which the elements can be spliced:
uf = Splice[{a, b}, f]{uf, uf}f[uf, uf]Possible Issues (2)
Most Wolfram Language functions automatically splice in Sequence objects:
Head[Sequence[a, b]]Assignment and replacement functions have the attribute SequenceHold:
u -> Sequence[a, b]See Also
FlattenAt BlankSequence SlotSequence PatternSequence List Listable SequenceHold Splice Nothing
Function Repository: BeheadAt
Tech Notes
History
Introduced in 1996 (3.0)
Text
Wolfram Research (1996), Sequence, Wolfram Language function, https://reference.wolfram.com/language/ref/Sequence.html.
CMS
Wolfram Language. 1996. "Sequence." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Sequence.html.
APA
Wolfram Language. (1996). Sequence. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Sequence.html
BibTeX
@misc{reference.wolfram_2026_sequence, author="Wolfram Research", title="{Sequence}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/Sequence.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_sequence, organization={Wolfram Research}, title={Sequence}, year={1996}, url={https://reference.wolfram.com/language/ref/Sequence.html}, note=[Accessed: 15-June-2026]}