>From map's docstring: "Returns a lazy sequence [...]"

So I guess you applied map at the top level and wondered why side-
effects didn't happen.

Try:

  (dorun (map #(form-with-side-effects %) a-list))

Or, for fun:

  (take 1 (map #(form-with-side-effects %))

Basically, since your map wasn't needed, it wasn't "realized"/
executed. Laziness.

Sean wrote:
> What I don't understand is why the
> doseq macro is required instead of the mapping operation.  Could
> somebody explain why Clojure has this different form for functions
> that have side effects?

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