This is pretty much a follow-up to my last question (Clojure idiomatic way to update multiple values of map), but not quite the same. (keep in mind that I'm fairly new to Clojure and functional languages alike)
suppose I have the following data structure, defined as a map of sets:
(def m1 {:1 #{2} :2 #{1 3} :3 #{1}})
and a map of maps as such:
(def m2 {:1 {:1 0 :2 12 :3 23} :2 {:1 23 :2 0 :3 4} :3 {:1 2 :2 4 :3 0}})
What I want to do is update the registries of m2 that have a correspondence in m1 to a certain value. Let's say the value I want is x. The resulting m2 would be something like this:
{:1 {:1 0 :2 x :3 23} :2 {:1 x :2 0 :3 x} :3 {:1 x :2 4 :3 0}}
Assuming that v contains every possible key for my map, y first attempt, (that I failed miserably) is to do something like this: (assume that x=1
(for [i v]
reduce (fn [m j] (assoc-in m [i j] 1)) d (i m1)))
needless to say that it was a failure. So, how is the idiomatic way to do this?