Clojure binding of dynamic var not working as expected

This is caused by lazyness – map returns a lazy sequence which is defined inside the binding but is evaluated outside. You need to force the evaluation from inside:

(binding [*out-dir* "/home/dave"] 
  (doall (map #(str *out-dir* %) [1 2 3])))

Leave a Comment