How do you evaluate a string as a clojure expression?

User> (eval (read-string "(+ 1 2)")) 3 You probably shouldn't ever need to do this. Macros and fns make this kind of thing unnecessary 99% of the time. This is quite brittle, and can be unsafe if these strings are coming from user input, and so on.

Well I want to do something radically unsafe: a REPL chatbot. – Nick Orton Dec 11 '09 at 15:43 There is a clojurebot in #clojure. – JH.

Dec 13 '09 at 19:01 4 load-string does exactly what he is looking for – Abhijith Dec 24 '09 at 17:39 you need it if you are saving Clojure data structures to a file for storage and then later restoring them, for example. – rplevy Dec 16 '10 at 2:26.

Clojure's eval works on lists, so: (eval (list + 1 2)) #=> 3.

I know about eval, but I don't think it works for me. I really want to evaluate a "String" – Nick Orton Dec 11 '09 at 2:35.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions