Unexpected output for card inside do

Why does this not lead to the expected result?

(defn test-fn [] (do (println "start") (map #(println (+ % 1)) '(1 2 3)) (println "done"))) 

He outputs

 start done 

While I would expect

 start 2 3 4 done 
+4
source share
1 answer

map lazy, but do not force it. If you want to force an evaluation of a lazy sequence, use doall or dorun .

 (defn test-fn [] (do (println "start") (dorun (map #(println (+ % 1)) '(1 2 3))) (println "done"))) 
+7
source

All Articles