PatternSequence[p1,p2,…]
is a pattern object that represents a sequence of arguments matching p1, p2, ….
PatternSequence
PatternSequence[p1,p2,…]
is a pattern object that represents a sequence of arguments matching p1, p2, ….
Details
- PatternSequence[] represents a sequence of zero length.
- PatternSequence can appear anywhere inside a pattern but cannot be the only element of a pattern.
Examples
open all close allBasic Examples (2)
Scope (2)
A pattern with both a and an empty PatternSequence as Alternatives:
f[a | PatternSequence[]] := xThe presence of a causes the result to be x:
f[a]Likewise, the empty PatternSequence matches and results in x:
f[]A list with just the element a or an empty list will be replaced with x:
{{a}, {}, {a, b}} /. {a | PatternSequence[]} -> xTech Notes
Related Guides
-
▪
- Patterns
History
Text
Wolfram Research (2007), PatternSequence, Wolfram Language function, https://reference.wolfram.com/language/ref/PatternSequence.html.
CMS
Wolfram Language. 2007. "PatternSequence." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PatternSequence.html.
APA
Wolfram Language. (2007). PatternSequence. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PatternSequence.html
BibTeX
@misc{reference.wolfram_2026_patternsequence, author="Wolfram Research", title="{PatternSequence}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/PatternSequence.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_patternsequence, organization={Wolfram Research}, title={PatternSequence}, year={2007}, url={https://reference.wolfram.com/language/ref/PatternSequence.html}, note=[Accessed: 12-June-2026]}