title: Transform a list of dictionaries to a dictionary of lists using the built-in dict commands
body: <p>I have a list of dictionaries:</p>
  
  <pre><code>set personA {name Alice age 35}
  set personB {name Bob age 42}
  set persons [list $personA $personB]
  </code></pre>
  
  <p>Now I want to "transpose" them to a single dictionary which contains lists instead:</p>
  
  <pre><code>set transposedPersons {name {Alice Bob} age {35 42}}
  </code></pre>
  
  <p>I can achieve this using the following piece of code:</p>
  
  <pre><code>set keys {name {} age {}}
  set transposedPersons [dict map {k _} $keys {
      lmap person $persons {dict get $person $k}
  }]
  </code></pre>
  
  <p>I don't fully understand what some of the built-in <a href="http://www.tcl.tk/man/tcl/TclCmd/dict.htm" rel="nofollow"><code>dict</code></a> commands do, like for example <code>dict merge</code>, <code>dict update</code> and <code>dict with</code>. I want to know if I can use one of them to simplify this dictionary-list transposition.</p>
  
  <p>Particularly: Can I somehow automatically use the keys <code>name</code> and <code>age</code> from the original dictionaries instead of having to write them out again?</p>
  
  <p>(I am restricted to Tcl 8.5, but would still be interested in a solution that requires Tcl 8.6.)</p>