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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to