title: Scala Convert For Loop to Functional Method
body: <p>I would like to convert the following for loop into a functional Scala method.</p>
  
  <pre><code>for (i &lt;- 15 to 25){
    count_table_rdd = count_table_rdd.union(training_data.map(line =&gt; (i+"_"+line(i)+"_"+line(0), 1)).reduceByKey(_ + _))
  }
  </code></pre>
  
  <p>I have tried look at the foreach method, but I do not want to transform every item, just 15 through 25. </p>