Fork me on GitHub

I can (dissoc {:id 1} :id). Is there an idomatic way to dissoc in specter, or should I nav to the map of interest and call my own function that calls dissoc?


(and yes, I searched the docs, bugs and source for “dissoc” first)

Chris O’Donnell15:08:54

@bill: you could do (view #(dissoc % :k)), but if you use that with transform, the key will not be added back during reconstruction

Chris O’Donnell15:08:19

you could also write your own navigator, which would be straightforward


thanks @codonnell. I don’t understand your caveat “the key will not be added back during reconstruction”. maybe I’m not being clear: I want the key (and value) removed from the hash.

Chris O’Donnell15:08:15

@bill: For example, (transform [(view #(dissoc % :a)) MAP-VALS] inc {:a 0 :b 0 :c 0}) gives {:b 1, :c 1}, not {:a 0, :b 1, :c 1}

Chris O’Donnell15:08:56

If you wrote your own navigator, you could make it have the latter behavior.


ah I get 60% of that which is enough—I think that’ll work for me. thanks!

Chris O’Donnell15:08:08

@bill: There are lots of examples on the wiki, including an example of a custom navigator at


so I here is me, removing the :ids:

(transform [:results ALL (view #(dissoc % :id)) MAP-VALS] identity {:foo 3 :results [{:id 0 :b 0 :c 0}]})
=> {:foo 3, :results [{:b 0, :c 0}]}
It works, but it seems like calling identity is a sign of wrongness here.

Chris O’Donnell15:08:05

@bill: I'm not at a repl, but I think you could do (transform [:results ALL] #(dissoc % :id) data)


perfecto! (works)


@bill I've used a function like this in the past:

(defn dissocer [k]
  (fn [m]
    (dissoc m k)))


then you can do (transform [:results ALL] (dissocer :a) data)