title: Spark: produce RDD[(X, X)] of all possible combinations from RDD[X]
body: <p>Is it possible in Spark to implement '.combinations' function from scala collections?</p>
  
  <pre><code>   /** Iterates over combinations.
     *
     *  @return   An Iterator which traverses the possible n-element combinations of this $coll.
     *  @example  `"abbbc".combinations(2) = Iterator(ab, ac, bb, bc)`
     */
  </code></pre>
  
  <p>For example how can I get from RDD[X] to RDD[List[X]] or RDD[(X,X)] for combinations of size = 2. And lets assume that all values in RDD are unique.</p>