Hi, Consider the following block of code:
## Sample Code (ns test) (def some-atom (atom {:tag :language :name "Clojure" :better-than ["scheme" "java" "ruby" "python"]})) (defn demo-func [] (swap! some-atom assoc-in [:name] "Clojure 1.6") (swap! some-atom assoc-in [:tag] :Language) (swap! some-atom update-in [:better-than] #(cons "javascript" %))) ;; I don't like the fact that things can happen between the swaps. (defn what-I-want [] (with-atom some-atom assoc-in ... assoc-in ... update-in ...)) ==> act as if a single (swap! some-atom .... all changes here ...) ## Question Now, what I don't like above is that the swap! in the first example can be interleaved with other swaps. Instead, I'd like all three swaps to happen all at once. Thus, I need to do something like: (swap! some-atom (fn [old] ... )) but, notationally, this is messy compared to a series of swap! Is there something like: "with-atom ..." which basically takes a series of changes, and puts them into a single "swap! ... " ? Thanks! (I apologize if this question is not clear; and if so, please tell me how I can make it more clear.) -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.