title: Breakdown of reduce function
body: <p>I currently have:</p>
  
  <pre><code>x.collect()  
  # Result: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  
  val a = x.reduce((x,y) =&gt; x+1) 
  # a: Int = 6
  
  val b = x.reduce((x,y) =&gt; y + 1)
  # b: Int = 12
  </code></pre>
  
  <p>I have tried to follow what has been said here (<a href="http://www.python-course.eu/lambda.php" rel="nofollow noreferrer">http://www.python-course.eu/lambda.php</a>) but still don't quite understand what the individual operations are that lead to these answers.</p>
  
  <p>Could anyone please explain the steps being taken here?</p>
  
  <p>Thank you.</p>