I'm trying to implement a map of dependents and dependencies. I stumbled across what looks like a function with the right behavior:
(defn immediate-dependents-impl [config]
(into #{}
(map first
(filter second
(keep-indexed
(fn [_ [k v]] [k (v config)]) immediate-dependencies-map)))))
and seeing as I'm throwing away the index in a keep-indexed call I figure I'm really looking for some other function or macro. Good news is, I have a test expression that returns true so long as the behavior is correct:
(every? identity (for [config configuration-names]
(every? config (map #(get extensions %) (immediate-dependents-impl config)))))
Thanks for this, I have never understood reduce-kv and I think I'm seeing what it's for now
It will help to see an example of the input data and an example of the result.
Looking at the shape of it, I feel like this whole thing can be done in a single reduce , like:
(defn immediate-dependents-impl
[config immediate-dependencies-map]
(reduce-kv (fn [deps-set k v]
(if (v config)
(conj deps-set k)
deps-set))
#{}
immediate-dependencies-map))