I’ve a code like this. I can run this in repl but can’t from command line.
I guess i’ve a lazy evaluation problem.
; items.clj
(def items (ref []))
(defn init-items []
(map
#(dosync
(alter items conj %))
["foo" "bar" "baz" ] ))
(init-items)
(println (first @items))
$ java -jar clojure.jar items.clj
$ nil
Regards.
Got it!
solution
Clojure is not motivated to run the
mapfunction ininit-itemsbecause there’s no result returned. I wrapped that into adoallto force execution, and presto.