Splice
Examples
open all close allBasic Examples (3)
Give a list of elements to be spliced into a surrounding list:
{a, b, c, Splice[{1, 2, 3}], d, e}Splice expressions do not automatically flatten inside other heads:
head[a, b, c, Splice[{1, 2, 3}], d, e]Flatten a list of lists inside another list:
{1, 2, Splice[{{3, 4}, {5, 6}}], 7, 8}Splice a list of elements inside an expression of a specific head:
head[a, b, c, Splice[{1, 2, 3}, head], d, e]Scope (3)
Splice a list of elements into another list:
{1, 2, 3, Splice[{a, b}], 4, 5}The same object does not splice into expressions with other heads:
f[1, 2, 3, Splice[{a, b}], 4, 5]Splice a list of elements into an expression with a given head:
f[1, 2, 3, Splice[{a, b}, f], 4, 5]The same object does not splice into expressions with other heads:
g[1, 2, 3, Splice[{a, b}], 4, 5]Splice a list of elements into an expression whose head matches a given pattern:
f[1, 2, 3, Splice[{x, y}, f | g], 4, 5]f[a][1, 2, 3, Splice[{x, y}, _f], 4, 5]Applications (1)
Properties & Relations (5)
Splice[{e1,e2,…}] behaves like Sequence[e1,e2,…] inside a list:
{a, b, c, Splice[{1, 2, 3}], d, e}{a, b, c, Sequence[1, 2, 3], d, e}Sequence objects also splice inside other heads, but not one-argument Splice objects:
head[a, b, c, Sequence[1, 2, 3], d, e]head[a, b, c, Splice[{1, 2, 3}], d, e]Splice[{e1,e2,…},_] behaves like Sequence[e1,e2,…] under evaluation:
f[a, b, c, Splice[{1, 2, 3}, _], d, e]f[a, b, c, Sequence[1, 2, 3], d, e]Splice[{}] is equivalent to Nothing:
{a, b, Splice[{}], c, d}{a, b, Nothing, c, d}FlattenAt[list,pos] is equivalent to MapAt[Splice,list,pos]:
FlattenAt[{a, {b, {c}}, d}, 2]MapAt[Splice, {a, {b, {c}}, d}, 2]Splice may be resolved inside functions with the HoldAll, HoldFirst, and HoldRest attributes:
Attributes[Hold]Hold[Splice[{a, b}, Hold]]It is not resolved inside functions with the HoldAllComplete attribute, as this attribute blocks upvalues:
Attributes[HoldComplete]HoldComplete[Splice[{a, b}, HoldComplete]]Splice is also not resolved when nested deeply inside a held expression:
Hold[{Splice[{a, b}]}]Possible Issues (1)
Unlike Sequence, the action of Splice cannot be blocked using Unevaluated:
Length[Unevaluated[Splice[{a, b}, _]]]Length[Unevaluated[Sequence[a, b]]]Instead, use Block if it is necessary to temporarily deactivate Splice:
Block[{Splice}, Length[Splice[{a, b}, _]]]Related Guides
Text
Wolfram Research (2020), Splice, Wolfram Language function, https://reference.wolfram.com/language/ref/Splice.html (updated 2022).
CMS
Wolfram Language. 2020. "Splice." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/Splice.html.
APA
Wolfram Language. (2020). Splice. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Splice.html
BibTeX
@misc{reference.wolfram_2026_splice, author="Wolfram Research", title="{Splice}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/Splice.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_splice, organization={Wolfram Research}, title={Splice}, year={2022}, url={https://reference.wolfram.com/language/ref/Splice.html}, note=[Accessed: 12-June-2026]}