title: Scala how to sum a list of futures
body: <p>I have written this code and it works</p>
  
  <pre><code>import scala.concurrent.{Future}
  import scala.concurrent.ExecutionContext.Implicits.global
  import scala.util.{Failure, Success, Random}
  
  object TestFuture2 {
    def bigCalc() : Future[Int] = Future {
      Thread.sleep(1000)
      40
    }
  }
  
  object Main2 extends App {
    val x = TestFuture2.bigCalc
    val y = TestFuture2.bigCalc
    val z = TestFuture2.bigCalc
  
    val v = for {
      r1 &lt;- x
      r2 &lt;- y
      r3 &lt;- z
    } yield (r1 + r2 + r3)
  
    v onSuccess {
      case x1 =&gt; println(x1)
    }
    System.in.read()
  }
  </code></pre>
  
  <p>So when I run this, I get 120. Good.</p>
  
  <p>but I don't like that I am summing the values in a for loop</p>
  
  <pre><code>for {
    r1 &lt;- x
    r2 &lt;- y
    r3 &lt;- z
  } yield (r1 + r2 + r3)
  </code></pre>
  
  <p>What if I called my functions like</p>
  
  <pre><code>val x = List(TestFuture2.bigCalc, TestFuture2.bigCalc, TestFuture2.bigCalc, TestFuture2.bigCalc, TestFuture2.bigCalc)
  </code></pre>
  
  <p>now how will I sum?</p>
  
  <p>I tried </p>
  
  <pre><code>x.reduce(_ + _)
  </code></pre>
  
  <p>but that doesn't work.  </p>
  
  <pre><code>scala&gt; x.reduce(_ + _)
  &lt;console&gt;:17: error: type mismatch;
   found   : scala.concurrent.Future[Int]
   required: String
                x.reduce(_ + _)
  </code></pre>