I have a persistent map which I want to filter. Something like this:
(filter #(-> % val (= 1)) {:a 1 :b 1 :c 2})
The above comes out as
Here's another one using reduce-kv
(defn filter-kv [pred map]
(reduce-kv (fn [accumulator key value]
(if (pred key value)
(assoc accumulator key value)
accumulator)) {} map))
Usage
(filter-kv (fn [key _]
(not (= key "a"))) {"a" {:some "a"}
"b" {:some "b"}
"c" {:some "c"}})
>> {"b" {:some "b"}
"c" {:some "c"}}