diff options
Diffstat (limited to 'src/clojure/contrib/core.clj')
-rw-r--r-- | src/clojure/contrib/core.clj | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/clojure/contrib/core.clj b/src/clojure/contrib/core.clj index e5fe7c78..55e5e777 100644 --- a/src/clojure/contrib/core.clj +++ b/src/clojure/contrib/core.clj @@ -42,3 +42,22 @@ (.?. nil .toUpperCase (.substring 1)) returns nil " .. .?.) + +;; ---------------------------------------------------------------------- +;; scgilardi at gmail + +(defn dissoc-in + "Dissociates an entry from a nested associative structure returning a new + nested structure. keys is a sequence of keys. Any empty maps that result + will not be present in the new structure." + [m [k & ks :as keys]] + (if ks + (if-let [nextmap (get m k)] + (let [newmap (dissoc-in nextmap ks)] + (if (seq newmap) + (assoc m k newmap) + (dissoc m k))) + m) + (dissoc m k))) + +;; ---------------------------------------------------------------------- |