Because unlike in CL, `map` in Clojure produces a lazy (and possibly
infinite) sequence. If the mapping function is impure then laziness
makes things harder to reason about.

If you want `map` like behaviour but don't want laziness, you can
check out `mapv` which returns a vector instead of a lazy sequence and
hence is not lazy.

-BG

On Thu, Dec 27, 2012 at 1:34 PM, Kruno Saho <kruno.s...@gmail.com> wrote:
> This code works:
>
>>   (doseq [q @draw-queue]
>>     (draw-entity screen q)))
>
>
> This code does not:
>
>> (map (fn [e] (draw-entity screen e)) @draw-queue)
>
>
>  The difference here is that `map` produces no side effects, while `doseq`
> expects side effects. In Common Lisp, `map` can take side effect creating
> functions. I am interested why this is not the case in Clojure.
>
> Thank You.
>
> --
> 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



-- 
Baishampayan Ghose
b.ghose at gmail.com

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

Reply via email to