As sepp2k rightly points out, constantly
is a function, so its argument will be evaluated only once.
The idiomatic way to achieve what you are doing here is to use doseq
:
(doseq [i (range 0 3)] (println "Loop it."))
Or, alternatively, dotimes
(this is a bit more concise and effective in this particular case, since you are not actually using the sequence generated by range
):
(dotimes [i 3] (println "Loop it."))
Both of these solutions are not lazy, which is probably what you need if you are just running some kind of code for side effects.
source share