title: Shifted Schwefel function implementation using Scala functional style
body: <p>Mathematical form of Shifted Schwefel function is described as follows. </p>
  
  <p><a href="https://i.stack.imgur.com/U50Bn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U50Bn.png" alt="enter image description here"></a></p>
  
  <p>I have implemented this function in scala using loops. Here is my code</p>
  
  <pre><code>def ShiftedSchwefel (   li  : List[Double]  ) : Double  =  {
   var res = 0.0
   for (i &lt;- li.indices ) {
    var temp = 0.0
    for (j &lt;- 0 to i) {
      temp += li(i)
    }
    res += pow    (  temp   ,   2  )
   }
   res
  }
  </code></pre>
  
  <p>How can I rewrite this code using functional power of Scala in optimized way?</p>