OpenersNotesSection(Spacer1)Details

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (7)

Interpret mathematical expressions:

Interpreter["MathExpression"]["1.4a+3"]

Interpreter["MathExpression"]["d f(x+2)/dx"]

Interpreter["MathExpression"]["y = b+3"]

The expression is evaluated:

Interpreter["MathExpression"]["1+2+3+4+5"]

Restrict to a list of choices:

Interpreter[Restricted["MathExpression",{{4,5}}]]["2+2"]

By default, all symbols are allowed. Restrict to a list of allowed symbols:

Interpreter[Restricted["MathExpression",{Plus,Times,Pi}]]["2 pi+2"]

Interpreter[Restricted["MathExpression",{Plus,Times,Pi}]]["2 pi^2"]

By default, new symbols are created in (RefLink[$Context, paclet:ref/$Context]), but a custom context can be specified:

Interpreter[Restricted["MathExpression",All,Automatic,Automatic]]["y + 2"]
Context[y]

Interpreter[Restricted["MathExpression",All,Automatic,"mycontext`"]]["k + 2"]
Context[k]

Specify contexts for the allowed and output symbols:

mycontext`b = 10;
Interpreter[Restricted["MathExpression",Automatic,{"mycontext`","System`"},"mycontext`"]]["a+b"]
Context[a]

Prevent the creation of any new symbol:

Interpreter[Restricted["MathExpression",Automatic,Automatic,None]]["3+1"]

Interpreter[Restricted["MathExpression",Automatic,Automatic,None]]["z+1"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Interpreter, paclet:ref/Interpreter])  ▪  (RefLink[SemanticImport, paclet:ref/SemanticImport])  ▪  (RefLink[Restricted, paclet:ref/Restricted])  ▪  (RefLink[Failure, paclet:ref/Failure])}, {Related Interpreter Types:  (RefLink[HeldMathExpression, paclet:ref/interpreter/HeldMathExpression])  ▪  (RefLink[InactiveMathExpression, paclet:ref/interpreter/InactiveMathExpression])  ▪  (RefLink[MathFormula, paclet:ref/interpreter/MathFormula])  ▪  (RefLink[Expression, paclet:ref/interpreter/Expression])  ▪  (RefLink[WolframLanguageSymbol, paclet:ref/interpreter/WolframLanguageSymbol])  ▪  (RefLink[HeldMathFormula, paclet:ref/interpreter/HeldMathFormula])  ▪  (RefLink[InactiveMathFormula, paclet:ref/interpreter/InactiveMathFormula])  ▪  (RefLink[HeldExpression, paclet:ref/interpreter/HeldExpression])  ▪  (RefLink[InactiveExpression, paclet:ref/interpreter/InactiveExpression])  ▪  (RefLink[SemanticExpression, paclet:ref/interpreter/SemanticExpression])  ▪  (RefLink[HeldSemanticExpression, paclet:ref/interpreter/HeldSemanticExpression])  ▪  (RefLink[InactiveSemanticExpression, paclet:ref/interpreter/InactiveSemanticExpression])  ▪  (RefLink[ComputedWolframLanguageSymbol, paclet:ref/interpreter/ComputedWolframLanguageSymbol])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Setting Up Input Interpreters, paclet:guide/InterpretingStrings])}})}})