You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Clojure
In the definition of dorun:
(defn dorun
"When lazy sequences are produced via functions that have side
effects, any effects other than those needed to produce the first
element in the seq do not occur until the seq is consumed. dorun can
be used to force any effects. Walks through the successive nexts of
the seq, does not retain the head and returns nil."
([coll]
(when (and (seq coll) (or (first coll) true))
(recur (next coll))))
([n coll]
(when (and (seq coll) (pos? n) (or (first coll) true))
(recur (dec n) (next coll)))))
Why do we evaluate (or (first coll) true) instead of just calling it
after the when?
I only bring this up because compiling with assert-if-lazy-seq=true
and running something like:
(doall (map range (repeat 0) (range 10)))
brings up a lazy seq exception.