I’m looking to write a function that is similar to assoc-in but removes keys instead of adding it:
(dissoc-in {:a {:b 0}} [:a :b])
;;=> {:a {}}
I got up to here:
(def m {:a {:b {:c 1}}})
(assoc m :a (assoc (:a m) :b (dissoc (:b (:a m)) :c)))
;;=> {:a {:b {}}}
but the whole nested thing is messing with my head
How about:
Example:
Result:
dissoc-inwas once part ofclojure.contrib.core, and is now part ofcore.incubator.If you want to keep empty maps, you can alter the code slightly:
Example:
Result: