Skip to content

Instantly share code, notes, and snippets.

@devn devn/gist:039ac6dbdb6587fa263d Secret
Created Nov 11, 2014

Embed
What would you like to do?
(defn filter-vals
[pred m]
(let [reduce-fn (fn [assoc-fn] (fn [m k v] (if (pred v) (assoc-fn m k v) m)))]
(if (instance? clojure.lang.IEditableCollection m)
(with-meta
(persistent! (reduce-kv (reduce-fn assoc!) (transient (empty m)) m))
(meta m))
(reduce-kv (reduce-fn assoc) (empty m) m))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.