Remove key from map based on predicate clojure

Viewed 1592

Say I have a map m like {"good1" 1, "bad1" 1, "good2" 2, "bad2" 2}, and I'd like to remove entries based on some predicate over the keys of the map, one way to do this would be:

(defn dissoc-by [f m] (->> m (filter (complement f)) (into {})))
(dissoc-by #(.contains (first %1) "bad") m)
 => {"good1" 1, "good2" 2}

Is there a more idiomatic way of doing this in clojure?

3 Answers
Related