I've been using assoc-in, get-in, etc, to work with nested maps, but I
recently needed a dissoc-in to free up unneeded indexes and such. I
didn't see one, so does this look about right?

(defn dissoc-in [m keys]
  (if (<= (count keys) 1)
    (dissoc m (first keys))
    (let [k (last keys)
          restkeys (butlast keys)
          submap (dissoc (get-in m restkeys) k)]
      (if (empty? submap)
        (recur m restkeys)
        (assoc-in m restkeys submap)))))
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to