In Clojure, how to define a variable named by a string?

Posted by Carl Smotricz on Stack Overflow See other posts from Stack Overflow or by Carl Smotricz
Published on 2010-03-21T10:46:47Z Indexed on 2010/03/21 10:51 UTC
Read the original article Hit count: 389

Filed under:
|
|

Given a list of names for variables, I want to set those variables to an expression.

I tried this:

(doall (for [x ["a" "b" "c"]] (def (symbol x) 666)))

...but this yields the error

java.lang.Exception: First argument to def must be a Symbol

Can anyone show me the right way to accomplish this, please?

© Stack Overflow or respective owner

Related posts about clojure

Related posts about def