How can I convert a string like "(+ ( - 5 2) 8)" to an s-expression (+ (- 5 2) 8) that can be evaluated in the Racket prompt? I tried string->symbol but it returns '|(+ ( - 5 2) 8)| which is not what I want.
The read function in racket (or any other lisp) does just this. Except read will read from an input port rather than a string. You can use open-input-string function for that.
(read (open-input-string "(+ (- 5 2))"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With