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

clojure, function, symbols

Solution

Clojure's "intern" function is for this purpose:

(doseq [x ["a" "b" "c"]]
  (intern *ns* (symbol x) 666))

Problem

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?

Original source