Closed henrygarner closed 11 years ago
This seems like a good addition, as I recall several times when I'd have found such a function useful.
However, if you write it as:
(defn filter-vals [pred coll]
(persistent! (reduce-kv #(if (pred %3) (assoc! %1 %2 %3) %1)
(transient (empty coll))
coll)))
It's about 6 times faster (according to some quick Criterium benchmarks).
Could you squash your commits, then I'll merge the changes in.
Thanks for the performance tip-off. I also prefer it stylistically.
I've squashed the commits into one.