Here is a more explicit answer why the second example does not work. The expression foris lazy; in other words, it is not evaluated if its result is not consumed by something. You throw away the result of the expression forbecause you only care about side effects, so it has never been evaluated.
Here is an example of the same phenomenon:
(defn example[]
(for [n (range 6)]
(println "n=" n))
(println "done"))
(example)
;; done
;; nil
source
share