title: Parallel function to perform element wise operations on a collection in Scala
body: <p>Using higher order methods in Scala, I can perform element wise operation on given collection as below</p>
  
  <pre><code>def fun1(l1 :List[Double], l2 :List[Double]) :List[Double] = (l1,l2).zipped.map((x,y) =&gt; x + y)
  </code></pre>
  
  <p>and using imperative way, I can do same operation much faster than <strong>fun1</strong> </p>
  
  <pre><code>def fun2(a1: Array[Double], a2: Array[Double]): Array[Double] = {
    val res = new Array[Double](a1.length)
    var i = 0
    while (i &lt; a1.length) {
      res(i) = a1(i) + a2(i)
      i += 1
    }
    res
  }
  </code></pre>
  
  <p>I want to write a parallel function that perform same operation. Using Scala, Can I paralyze any of above functions? If not how can I write parallel function that achieves pure functional parallelism for element wise operations on collections?</p>