title: How to parallelize list iteration and be able to create RDDs in Spark?
body: <p>I've just started learning Spark and Scala. </p>
  
  <p>From what I understand it's bad practice to use <code>collect</code>, because it gathers the whole data in memory and it's also bad practice to use <code>for</code>, because the code inside the block is not executed concurrently by more than one node. </p>
  
  <p>Now, I have a List of numbers from 1 to 10:</p>
  
  <p><code>List(1,2,3,4,5,6,7,8,9,10)</code> </p>
  
  <p>and for each of these values I need to generate a <code>RDD</code> using this value. </p>
  
  <p>in such cases, how can I generate the <code>RDD</code>? </p>
  
  <p>By doing </p>
  
  <pre><code>sc.parallelize(List(1,2,3,4,5,6,7,8,9,10)).map(number =&gt; generate_rdd(number))
  </code></pre>
  
  <p>I get an error because RDD cannot be generated inside another RDD.</p>
  
  <p>What is the best workaround to this problem? </p>