title: Reverse iteraror RDD
body: <p>I have code on a pure Scala of the following kind:</p>
  
  <pre><code>import breeze.numerics.log
  import spire.random.Dist
  import org.apache.commons.math3.distribution.NormalDistribution
  import scala.collection.mutable.Buffer
  
  
  def foo1(zs: Buffer[Double])={
    val S = zs.zip(zs.reverse)
      .map { case (x, y) =&gt;log(x) * log(1 - y) }.sum
    S
  }
  
  val x = Dist.uniform(0.0, 1.0).sample[Buffer](10)
  val y = x.sortWith(_&lt;_)
  val cdf=new NormalDistribution(0, 1)
  val z = y.map(x_ =&gt; cdf.cumulativeProbability(x_))
  
  foo1(z)
  </code></pre>
  
  <p><code>z</code> is sorted because the <code>cdf</code> is increasing</p>
  
  <p>I want to rewrite it for Spark, but for the RDD data type there's no reverse method. How do I write this code for Spark?</p>
  
  <pre><code>def foo2(z_rdd: RDD[Double])={
      var S = z_rdd.zip(z_rdd.???)
      .map { case (x, y) =&gt;log(x) * log(1 - y) }.sum
      S
  }
  </code></pre>
  
  <p>where <code>???</code>function that is reversed <code>z_rdd</code>.</p>