Wondering if you'd be open to a function index-and-map-by generalizing over index-by like the following:
(defn index-and-map-by
[kf vf coll]
(into {}
(map
(fn [x]
[(kf x) (vf x)]))
coll))
(Of course, you might want to improve the peformance of this implementation, e.g with reduce and transients).
(index-and-map-by kf vf coll) would be equivalent to (->> coll (index-by kf) (map-vals vf))
I'm asking because I keep defining this index-and-map-by function in my projects.
Wondering if you'd be open to a function
index-and-map-bygeneralizing overindex-bylike the following:(Of course, you might want to improve the peformance of this implementation, e.g with
reduceand transients).(index-and-map-by kf vf coll)would be equivalent to(->> coll (index-by kf) (map-vals vf))I'm asking because I keep defining this
index-and-map-byfunction in my projects.