Skip to main content
added 192 characters in body
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489

How to execute a String code in the form of StandardForm?

I want to get execution results for strings of various forms. For this, I used ToExpression.

case1 = ToExpression["(1/2)^3"]
case2 = ToExpression["\!\(\*SuperscriptBox[FractionBox[\(1\), \(2\)], \(3\)]\)"]
case3 = ToExpression["(\!\(\*FractionBox[\(1\), \(2\)]\)\!\(\*SuperscriptBox[\()\), \\(3\)]\)"]

enter image description here

As a result of execution, Case 3 did not get the result I wanted. How can I solve it?


Here's a GIF showing how 3rd string is created:

gif

As we can see, once the pair of " is added, the size of () becomes a bit weird.

How to execute a String code in the form of StandardForm?

I want to get execution results for strings of various forms. For this, I used ToExpression.

case1 = ToExpression["(1/2)^3"]
case2 = ToExpression["\!\(\*SuperscriptBox[FractionBox[\(1\), \(2\)], \(3\)]\)"]
case3 = ToExpression["(\!\(\*FractionBox[\(1\), \(2\)]\)\!\(\*SuperscriptBox[\()\), \\(3\)]\)"]

enter image description here

As a result of execution, Case 3 did not get the result I wanted. How can I solve it?

How to execute a String code in the form of StandardForm?

I want to get execution results for strings of various forms. For this, I used ToExpression.

case1 = ToExpression["(1/2)^3"]
case2 = ToExpression["\!\(\*SuperscriptBox[FractionBox[\(1\), \(2\)], \(3\)]\)"]
case3 = ToExpression["(\!\(\*FractionBox[\(1\), \(2\)]\)\!\(\*SuperscriptBox[\()\), \\(3\)]\)"]

enter image description here

As a result of execution, Case 3 did not get the result I wanted. How can I solve it?


Here's a GIF showing how 3rd string is created:

gif

As we can see, once the pair of " is added, the size of () becomes a bit weird.

Became Hot Network Question
add bug tag
Link
AsukaMinato
  • 10.4k
  • 1
  • 17
  • 44
edited tags
Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
Source Link
Milk
  • 1.8k
  • 10
  • 9
Loading