FixedOrder[p1,p2,…]
is a grammar rules pattern object that represents a sequence of elements matching p1, p2, …, in the fixed order given.
FixedOrder
FixedOrder[p1,p2,…]
is a grammar rules pattern object that represents a sequence of elements matching p1, p2, …, in the fixed order given.
Details
- FixedOrder appears inside GrammarRules and StringExpression objects.
- FixedOrder can be nested inside and outside AnyOrder, Alternatives, and other grammar rules patterns.
Examples
open all close allBasic Examples (2)
Deploy a grammar that requires elements to appear in a particular order:
grammar = CloudDeploy[
GrammarRules[{FixedOrder[from : GrammarToken["City"], "to", to : GrammarToken["Ocean"]] :> from -> to}]
]GrammarApply[grammar, "Boston to the Pacific"]Extract elements of a string that appear in a particular order:
StringCases["abc123 456def", FixedOrder[LetterCharacter.., DigitCharacter..]]By default, elements of StringExpression are already ordered:
StringCases["abc123 456def", LetterCharacter.. ~~ DigitCharacter..]Applications (1)
Deploy a simple calculator that supports infix operators, including precedence:
calc = CloudDeploy[
GrammarRules[{GrammarToken["Addition"], GrammarToken["Multiplication"], GrammarToken["SemanticNumber"]}, {
"Summand" -> s : (GrammarToken["Addition"] | GrammarToken["Multiplication"] | GrammarToken["SemanticNumber"]) :> s,
"Multiplicand" -> m : (GrammarToken["Multiplication"] | GrammarToken["SemanticNumber"]) :> m,
"Addition" -> FixedOrder[a : GrammarToken["Summand"], "+", b : GrammarToken["Summand"]] :> a + b,
"Addition" -> FixedOrder[a : GrammarToken["Summand"], "-", b : GrammarToken["Summand"]] :> a - b,
"Multiplication" -> FixedOrder[a : GrammarToken["Multiplicand"], "*", b : GrammarToken["Multiplicand"]] :> a * b,
"Multiplication" -> FixedOrder[a : GrammarToken["Multiplicand"], "/", b : GrammarToken["Multiplicand"]] :> a / b
}]
]Apply the calculator grammar and actions:
GrammarApply[calc, "2+3"]GrammarApply[calc, "two + three / four"]GrammarApply[calc, "two+one/forty-five"]Related Guides
History
Text
Wolfram Research (2015), FixedOrder, Wolfram Language function, https://reference.wolfram.com/language/ref/FixedOrder.html.
CMS
Wolfram Language. 2015. "FixedOrder." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FixedOrder.html.
APA
Wolfram Language. (2015). FixedOrder. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FixedOrder.html
BibTeX
@misc{reference.wolfram_2026_fixedorder, author="Wolfram Research", title="{FixedOrder}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/FixedOrder.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_fixedorder, organization={Wolfram Research}, title={FixedOrder}, year={2015}, url={https://reference.wolfram.com/language/ref/FixedOrder.html}, note=[Accessed: 12-June-2026]}