title: Summing values in a List
body: <p>I'm trying to write a scala function which will recursively sum the values in a list. Here is what I have so far : </p>
  
  <pre><code>  def sum(xs: List[Int]): Int = {
      val num = List(xs.head)   
      if(!xs.isEmpty) {
        sum(xs.tail)
      }
      0
     }
  </code></pre>
  
  <p>I dont know how to sum the individual Int values as part of the function. I am considering defining a new function within the function sum and have using a local variable which sums values as List is beuing iterated upon. But this seems like an imperative approach. Is there an alternative method ?</p>