On Tue, Mar 3, 2009 at 10:03 AM, Mark Volkmann <r.mark.volkm...@gmail.com> wrote: > > Does this seem like a good way to choose between doall, dorun, doseq > and for to evaluate all the items in sequences? > > Ask these questions: > > Do you already have the lazy sequence in a variable or do you still > need to build it? > If you already have it, use dorun or doall. Otherwise use doseq or for.
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. 'for' is in rather a different category, since unlike the others it produces a lazy seq rather than forcing anything. Use 'for' when it's a more convenient way to express the lazy seq you want than the equivalent combination of map, filter, take-while, etc. --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---