On Tue, Mar 3, 2009 at 9:42 AM, Chouser <chou...@gmail.com> wrote:
>
> If you have a lazy sequence with side-effects, you almost certainly
> don't want to let it out of your sight.  You're likely to get very
> strange behavior unless you're exceedingly careful.  Most likely, if
> you've got a lazy seq with side effects you should force it with dorun
> or doall immediately.  Use doall if you care about the values in the
> produced seq, otherwise use dorun.
>
> This means that dorun should almost always show up right next to the
> form producing the lazy seq, which means doseq is very likely a better
> choice, as it is more efficient and usually more succinct than dorun
> combined with a lazy-seq producer.

I agree that using doseq instead of dorun results in code that is
easier to read. I don't understand though why it is more efficient.
They both walk the entire sequence, neither holds onto the head and
both return nil. Why is doseq more efficient than dorun?

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~---------~--~----~------------~-------~--~----~
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