TemplateSequence[body,list]
represents an element of a template object that yields a sequence consisting of body applied to each element in list.
TemplateSequence
TemplateSequence[body,list]
represents an element of a template object that yields a sequence consisting of body applied to each element in list.
Details and Options
- When a template containing TemplateSequence[body,list] is applied, the TemplateSequence is effectively expanded to Map[TemplateApply[body,#]&,list].
- TemplateSequence has the following options:
-
InsertionFunction Inherited function to apply before inserting each element Delimiters Sequence[] delimiters to insert between elements "DefaultValue" Sequence[] default content to render if the sequence is empty - In an XML template, TemplateSequence can be indicated using <wolfram:sequence>...</wolfram:sequence>.
- A separator can be given by using attribute delimiters='…'.
Examples
open all close allBasic Examples (2)
TemplateSequence returns a Sequence:
TemplateApply[TemplateSequence[StringTemplate["x ``"], {a, b, c, d}]]Template sequences splice into lists:
TemplateApply[{a, TemplateSequence[b, {1, 2, 3}], c}]Options (3)
InsertionFunction (1)
Use InsertionFunction to process all TemplateSlot input:
t = TemplateSequence[
{TemplateSlot[1], TemplateSlot[2], TemplateSlot[3]},
TemplateSlot["data"],
InsertionFunction -> Function[# * 100]
];
TemplateApply[t, <|"data" -> {Range[3, 5], Range[5, 7], Range[10, 12]}|>]"DefaultValue" (1)
Delimiters (1)
Use Delimiters to provide a separator that is inserted between elements:
t = {start, TemplateSequence[TemplateSlot[1], TemplateSlot["data"], Delimiters -> separator], ending};
TemplateApply[t, <|"data" -> {a, b, c}|>]t = TemplateSequence[TemplateSlot[1], TemplateSlot["data"], Delimiters -> Sequence[x, y]];
TemplateApply[t, <|"data" -> {a, b, c}|>]See Also
Related Guides
History
Text
Wolfram Research (2014), TemplateSequence, Wolfram Language function, https://reference.wolfram.com/language/ref/TemplateSequence.html.
CMS
Wolfram Language. 2014. "TemplateSequence." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TemplateSequence.html.
APA
Wolfram Language. (2014). TemplateSequence. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TemplateSequence.html
BibTeX
@misc{reference.wolfram_2026_templatesequence, author="Wolfram Research", title="{TemplateSequence}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/TemplateSequence.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_templatesequence, organization={Wolfram Research}, title={TemplateSequence}, year={2014}, url={https://reference.wolfram.com/language/ref/TemplateSequence.html}, note=[Accessed: 12-June-2026]}