title: Sum of Integers Using a List
body: <p>I've been trying to finish this scala code that uses a list to output the summation of all positive integers in the list.. I got it working except for having it only work for positive numbers. but i cant get it to only output the positive numbers. I have 2 versions that ive been trying to get to work, i thought maybe it would be easier wit cases, but i ended up running into the same problem. I've been trying if statements with xs&lt;0 , but those don't work, and i cant get the filter to work with the fold. any suggestions with how to handle this?</p>
  
  <pre><code>def sum(xs: List[Int]): Int = {
  
  xs.filter((x: Int) =&gt; x &gt; 0)
  
  xs.foldLeft(0) { _ + _ }
  
  }
  
  def sum2(xs: List[Int]): Int = xs match {
  
  case Nil =&gt; 0
  case y :: ys =&gt; y + sum(ys)
  }
  </code></pre>