Re: Map vs Doseq on agents

2012-12-27 Thread Marko Topolnik
Clojure's *map* is agnostic to whether the mapping function has side effects. The only thing to keep in mind is that *map* is not imperative, but declarative: it gives you a lazy sequence whose elements will be the results of the mapping function. As soon as you realize the sequence, for exampl

Re: Map vs Doseq on agents

2012-12-27 Thread Baishampayan Ghose
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

Map vs Doseq on agents

2012-12-27 Thread Kruno Saho
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 creati