Oh, I see the return value for doall.

When I look at dorun it is different than lots of other functions.
Unlinke lots of other functions that do conj, cons, etc. dorun just
extract each element of coll.  Is each element get evaluated if it's a
code?

Thanks
-sun



(defn dorun
  ([coll]
   (when (and (seq coll) (or (first coll) true))
     (recur (rest coll))))



On Jan 25, 6:21 pm, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> On Jan 25, 2009, at 5:51 PM, wubbie wrote:
>
> > I saw dorun and doall  in core.clj as follows:
> > That is, doall just calls dorun.
> > My question is, how come doall does force eval and dorun does not.
> > thanks in advance,
>
> Both force evaluation. Immediately before either returns, there is a  
> fully realized sequence in memory.
>
> The difference is in their return value:
>
> - dorun returns nil. A call to dorun indicates:
>
>         "all the work I want done is done in the evaluation of the elements  
> of the sequence, I don't plan to work with the entire sequence after  
> it's realized"
>
> - doall returns the head of the realized sequence. A call to doall  
> indicates:
>
>         "not only do I want the entire sequence realized, I also want to use  
> the resulting sequence subsequently"
>
> It's good form to save or otherwise use the value returned by doall.
>
> --Steve
>
>  smime.p7s
> 3KViewDownload
--~--~---------~--~----~------------~-------~--~----~
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
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