Hello Mark,

Just one point :

2009/3/3 Mark Volkmann <r.mark.volkm...@gmail.com>

>
> 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.
> While code inside a dorun or doall could build the sequence, using
> doseq and for are considered more idiomatic/readable.
> Also, they provide list comprehension features such as processing more
> than one sequence and filtering with :when/:while.
>
> For example, instead of using the following to get a new sequence
> where all the items are multiplied by two:
> (doall (map #(* % 2) my-coll))
> use this:
> (for [item my-coll] (* item 2))


I don't think it is a good example, since it conveys the idea that it could
be interesting to use doall or for for mapping a coll to multiply its items.
This example, in which there is no side effect at all in the inner loop, is
really typical of the use of map ! And forcing the sequence there gives you
nothing (?)

Maybe a more interesting example could be something that touches global
vars, or does IO, ... ?

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