Because the fn is wrapped in a lazy sequence, the effects won't run if you 
ask for the same value again-- 

For instance:

(def a (iterate (fn [cnt]
                (prn cnt)
                ;; save data to csv
                (inc cnt)) 0))

(nth a 5) ... all the effects are fired.
(nth a 5) ... simply returns 5-- no effects are fired because the lazy 
sequence has already been realized up to this point. This may not be what 
you expect.

Also, you shouldn't in general trust effects to be run the 'correct' amount 
of times. For instance, if we were operating on a chunked-sequence, if you 
asked for the 3rd element, you would get the side effects for the next 32 
elements, which may not be what you'd expect. That doesn't happen to be the 
case here but it's something to keep in mind as well.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to