OpenersNotesSection(Spacer1)Details

OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (6)

Interpret MathML inputs:

Interpreter["MathMLExpression"]["<math><mrow><mi>sin</mi><mo>&#8289;</mo><mo>(</mo><mi>x</mi><mo>)</mo></mrow></math>"]

Interpreter["MathMLExpression"]["<math><mrow><mn>2</mn><mo>+</mo><mn>2</mn></mrow></math>"]

Restrict to a list of choices:

Interpreter[Restricted["MathMLExpression",{{3,4}}]]["<math><mrow><mn>2</mn><mo>+</mo><mn>2</mn></mrow></math>"]

Interpreter[Restricted["MathMLExpression",{{True, False}}]]["<math><mrow><mi>x</mi><mo>+</mo><msup><mi>&#8519;</mi><mi>y</mi></msup></mrow></math>"]

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

Interpreter[Restricted["MathMLExpression",{Plus}]]["<math><mrow><mn>2</mn><mo>+</mo><mn>2</mn></mrow></math>"]

Interpreter[Restricted["MathMLExpression",{Plus}]]["<math><mrow><mn>2</mn><mo>*</mo><mn>2</mn></mrow></math>"]

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

var=Interpreter[Restricted["MathMLExpression",Automatic,Automatic,Automatic]]["<math><mrow><mn>x</mn></mrow></math>"]
Context[Evaluate[var]]

var=Interpreter[Restricted["MathMLExpression",Automatic,Automatic,"mycontext`"]]["<math><mrow><mn>x</mn></mrow></math>"]
Context[Evaluate[var]]

Specify contexts for the allowed and output symbols:

Global`x = 10;
Interpreter[Restricted["MathMLExpression",Automatic,{"Global`","System`"},"Global`"]]["<math><mrow><mn>x</mn></mrow></math>"]

Prevent the creation of any new symbol:

Interpreter[Restricted["MathMLExpression",Automatic,Automatic,None]]["<math><mrow><mn>2</mn><mo>+</mo><mn>2</mn></mrow></math>"]

Interpreter[Restricted["MathMLExpression",Automatic,Automatic,None]]["<math><mrow><mn>z</mn><mo>+</mo><mn>2</mn></mrow></math>"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MathMLForm, paclet:ref/MathMLForm])  ▪  (RefLink[Interpreter, paclet:ref/Interpreter])  ▪  (RefLink[Restricted, paclet:ref/Restricted])  ▪  (RefLink[Failure, paclet:ref/Failure])}, {Related Interpreter Types:  (RefLink[HeldMathMLExpression, paclet:ref/interpreter/HeldMathMLExpression])  ▪  (RefLink[InactiveMathMLExpression, paclet:ref/interpreter/InactiveMathMLExpression])  ▪  (RefLink[TeXExpression, paclet:ref/interpreter/TeXExpression])  ▪  (RefLink[HeldTeXExpression, paclet:ref/interpreter/HeldTeXExpression])  ▪  (RefLink[InactiveTeXExpression, paclet:ref/interpreter/InactiveTeXExpression])}, {Related Formats:  (RefLink[LaTeX, paclet:ref/format/LaTeX])  ▪  (RefLink[XHTML, paclet:ref/format/XHTML])}})}})

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