On Fri, Jun 8, 2012 at 9:54 AM, Allen Johnson <akjohnso...@gmail.com> wrote: > Combine map with dorun and you get the same effect: > > (dorun (map println logs)) > > http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/dorun > > Allen > > On Thu, Jun 7, 2012 at 11:32 PM, David Jacobs <da...@wit.io> wrote: >> I would love to have a version of doseq that works like map (similar to >> "each" in other dynamic languages). In other words, instead of (doseq [log >> logs] (println log)), I would say something like (each println logs). >> >> Is there a built-in Clojure method that works like this?
Not a built-in, but... (defmacro for-each [f x] `(doseq [item# ~x] (~f item#))) I suppose this solution is blindingly obvious though. Also, I would be curious if there's any significant performance difference using (dorun (map ...)) as I assume an intermediate result is built and then thrown away. Or perhaps it's insignificant compared to what the unspecified function does that is passed to map for performing the side-effect work.. Lars Nilsson -- 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 Note that posts from new members are moderated - please be patient with your first post. 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