Tim Robinson <tim.blacks...@gmail.com> writes: > => (defn oops! [] > (let [x1 (atom (hash-map)) > v1 (filter > #(let [xv1 (@data %)] > (if (= xv1 "v1") > (swap! x1 assoc :k1 "other"))) > (keys @data)) > rxv (reset! flag @x1)] > (println v1)))
> So why didn't the first version with deref work? Because `filter' produces a lazy list, which isn't realized (and the side effects generated) until your call to `println'. Furthermore, the documentation for `filter' explicitly notes that "pred must be free of side-effects." Looking at the implementation, I'm not sure why function-argument purity matters more for `filter' than any other sequence-generating higher-order function. Does anyone else know the reason? -Marshall -- 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