title: Scala - Reduce list of tuples by key
body: <p>I have list of tuples which contains <code>userId</code> and <code>point</code>. I want to combine or reduce this list by the key.</p>
  
  <pre><code>val points: List[(Int, Double)] = List(
    (1, 1.0),
    (2, 3.2),
    (4, 2.0),
    (1, 4.0),
    (2, 6.8)
  )
  </code></pre>
  
  <p>The expected result should look like:</p>
  
  <pre><code>List((1, 5.0), (2, 10.0), (4, 2.0))
  </code></pre>
  
  <p>I tried with <code>groupBy</code> and <code>mapValue</code>, but got an error:</p>
  
  <pre><code>val aggrPoint: Map[Int, Double] = incomes.groupBy(_._1).mapValues(seq =&gt; seq.reduce(_._2 + _._2))
  
  Error:(16, 180) type mismatch;
   found   : Double
   required: (Int, Double)
  </code></pre>
  
  <p>What am I doing wrong, and is there a idiomatic way to achieve this?</p>
  
  <p>P.S) I found that in Spark <code>aggregateByKey</code> does this job. But, is there a built-in method in Scala?</p>