Post Reply 
How to get textbook display of an expression held in a string?
07-01-2015, 12:59 AM
Post: #1
How to get textbook display of an expression held in a string?
I have a piece of code that generates an expression as a string. I can't find a way to convert it into a CAS expression (within the program and without simplifying or evaluating it) so that it displays pretty-printed in textbook mode on the history stack when the program ends.

Typical example is: "3 NTHROOT (1/8)" which I'd like to see displayed as:
\begin{equation}
\sqrt[3]{1/8}
\end{equation}

Any suggestions, please?
Find all posts by this user
Quote this message in a reply
07-01-2015, 01:43 AM
Post: #2
RE: How to get textbook display of an expression held in a string?
If s is your string, then the following should work:
Code:
EXPR("'" + s + "'")
or
Code:
EXPR("QUOTE(" + s + ")")
Find all posts by this user
Quote this message in a reply
07-01-2015, 10:37 PM
Post: #3
RE: How to get textbook display of an expression held in a string?
Thanks, the latter version did the trick. I felt sure that I had tried every combination of QUOTE, EXPR and EVAL but clearly not. Thanks again.
Find all posts by this user
Quote this message in a reply
07-02-2015, 03:54 AM
Post: #4
RE: How to get textbook display of an expression held in a string?
Both versions work in the tests I've done. Do you have an example where the first one would not work ?
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)