02 Sep 2011, 18:40
Generic-user-small

Kevin Graham (5 posts)

Can you clarify what is happening with doall/dorun in the sequence chapter?

Running the following for example gives the following results:

(def x (for [ i (range 1 3)] (do (println i) i)))

(doall x)
(doall x)

---------------------

#'user/x
1
2
(1 2)
(1 2)

It appears that the println is only run once. This makes me think x is defined on doall and is only “initialized” once (if anyone has a better term than initialized, please let me know). Can you clarify why the println is not run twice?

Thanks,

Kevin

  You must be logged in to comment