title: Scala group by mapping keys
body: <p>Say I have a map like this:</p>
  
  <pre><code>val m: Map[Int, String] = Map(1 -&gt; "a", 2 -&gt; "b", 3 -&gt; "c", 4 -&gt; "d", ...)
  </code></pre>
  
  <p>Say I have a function: <code>def f(i: Int): String</code> that I want to apply to the keys of this map. I then want to group by the resulting f(key) and concatenate all the strings (values) belonging to the same f(key) group.</p>
  
  <p>Is there an efficient way to "groupByKey" while mapping the key in plain scala (no spark).</p>