[racket] convert string to evaluatable code

From: Noel Welsh (noelwelsh at gmail.com)
Date: Wed Oct 13 09:25:18 EDT 2010

On Tue, Oct 12, 2010 at 3:45 PM, 김태윤 <kty1104 at gmail.com> wrote:
> what I have to do for change string to evaluatable code?

This should do it:

Welcome to Racket v5.0.1.2.
> (define (string->expr str)
    (read (open-input-string str)))
> (string->expr "(+ 1 2)")
'(+ 1 2)
> (eval (string->expr "(+ 1 2)"))
3

Cheers,
N.


Posted on the users mailing list.