Sequence¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
Sequence[e1, e2, ...]
represents a sequence of arguments that is automatically spliced into the argument list of any enclosing function. Sequence[] evaporates and Sequence[e] acts like the identity. Splicing is suppressed for heads with the attribute SequenceHold or HoldAllComplete.
Examples (3)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (3)¶
In[1]:= f[a, Sequence[b, c], d]
Out[1]= f[a, b, c, d]
In[2]:= {a, Sequence[b], c, Identity[d]}
Out[2]= {a, b, c, d}
In[3]:= {a, b, g[x, y], h[w], g[z, y]} /. g -> Sequence
Out[3]= {a, b, x, y, h[w], z, y}
Implementation notes¶
- Attributes:
{Protected}. - Splicing happens structurally during evaluation, before
Flat/Listable/Orderless:f[a, Sequence[b, c], d]becomesf[a, b, c, d]. Sequence[]evaporates andSequence[e]acts like the identity, so{a, Sequence[b], c}gives{a, b, c}and{Sequence[], a}gives{a}.- A bare
Sequence[...]with no enclosing function (including one stored in anOwnValue) is left as aSequenceobject; it only splices at a call site. Sequenceis the wrapper produced byBlankSequence/BlankNullSequence(f[a, b, c] /. f[x__] -> xgivesSequence[a, b, c]) and bySlotSequence(##& [a, b, c]givesSequence[a, b, c]).- Splicing is suppressed for heads carrying
SequenceHoldorHoldAllComplete.
Attributes: Protected.
References¶
See also: Flat, Orderless, BlankSequence, BlankNullSequence, SlotSequence, SequenceHold, HoldAllComplete
- Source:
src/info.c - Specification:
docs/spec/builtins/expression-information.md - Tests:
tests/test_eval_eager_exit.c - Tests:
tests/test_evaluate.c - Tests:
tests/test_expr_pool.c - Tests:
tests/test_expr_sharing.c