Dominik G
Dominik G

Reputation: 1479

Clojure get form from string

I want to read some code from a file and give this to a macro as a form. Since I need the form unevaluated I cannot use "load-string".

Is there a possibility to get a form from a string?

e.g the string is "(3 4 +)" and I would like to convert it to prefix notation by a macro of mine. (That is not the real use case here but it is a simple example.)

I hope someone can help me.

Upvotes: 2

Views: 219

Answers (1)

Jonas
Jonas

Reputation: 19642

You should look at read and read-string. As an example:

user=> (read-string "(3 4 +)")
(3 4 +)

Upvotes: 3

Related Questions