I wrote this based on assoc-in. If anyone thinks this should be in core or contrib, feel free to use it.
(defn assoc-in-by "'Updates' a value in a nested associative structure, where ks is a sequence of keys and (f v) is the new value and returns a new nested structure. If any levels do not exist, hash-maps will be created." [m [k & ks] f] (if ks (assoc m k (assoc-in-by (get m k) ks f)) (assoc m k (f (get m k))))) user> (assoc-in-by {:1 1 :2 {:3 3}} [:2 :3] inc) {:1 1, :2 {:3 4}} --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---