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