I have a function that removes a key from a map:
(defn remove-key [key map]
(into {}
(remove (fn [[k v]] (#{key} k))
map)))
(remov
Your remove-key
function is covered by the standard library function dissoc
. dissoc
will remove more than one key at a time, but it wants the keys to be given directly in the argument list rather than in a list. So you can use apply
to "flatten" it out.
(apply dissoc {:foo 1, :bar 2, :baz 3} [:foo :bar])
==> {:baz 3}