[racket] What is the equivalent of ToExpression in Mathematica?

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Wed Feb 29 16:28:15 EST 2012

ashok bakthavathsalam wrote at 02/29/2012 04:18 PM:
> I am looking for something similar to ToExpression 
> <http://reference.wolfram.com/mathematica/ref/ToExpression.html> that 
> is available in Mathematica. I just want to convert a string to an 
> expression, and evaluate the expression.

There is "eval" and similar procedures, but using that is rare outside 
of textbooks, and usually there is a better way to do things, such as 
with syntax transformers, dynamic requires, etc.  Exactly what you use 
depends on what you are trying to accomplish.

It's good to know that "eval" is there, in case you ever need it, but 
most people will never need it, even if they think they do.

> As a first pass, my strings will include only numbers and arithmetic 
> operators, and not even parentheses.

For that, you may want "read" or "read-syntax".

-- 
http://www.neilvandyke.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120229/58d78b68/attachment.html>

Posted on the users mailing list.