The functions get-in, assoc-in, update-in are really useful. Just wanted to share a thoughts.
user=> (def m {:a {:b {:c 10 :c1 20} :b1 90} :a1 100}) #'user/m 1. Lets see the behavior of these functions in the corner case of empty keyseq: user=> (get-in m []) {:a {:b {:c 10, :c1 20}, :b1 90}, :a1 100} user=> (assoc-in m [] 42) {nil 42, :a {:b {:c 10, :c1 20}, :b1 90}, :a1 100} user=> (update-in m [] assoc :a2 42) {nil {:a2 42}, :a {:b {:c 10, :c1 20}, :b1 90}, :a1 100} get-in, assoc-in pretty much behave the way I would expect them to but update-in is wierd especially considering get-in's output. How about this: user=> (update-in-2 m [] assoc :a2 42) {:a2 42, :a {:b {:c 10, :c1 20}, :b1 90}, :a1 100} (defn update-in-2 [m ks f & args] (if (= 0 (count ks)) (apply f m args) (let [[k & ks] ks] (assoc m k (apply update-in-2 (get m k) ks f args))))) 2. There's no dissoc-in ! With the above definition of update-in-2, dissoc-in is simply: (defn dissoc-in [m ks] (update-in-2 m (butlast ks) dissoc (last ks))) Even assoc-in is simply: (defn assoc-in [m ks v] (update-in-2 m (butlast ks) assoc (last ks) v)) Can we please have dissoc-in in core. - Thanks -- 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