title: How to convert each integers to its absolute value in Scala lists?
body: <p>I am trying to convert each list integer to its absolute value using the following Scala statement, I am getting an invalid type match error:</p>
  
  <pre><code>def f(arr:List[Int]):List[Int] = arr.map((x: Int) =&gt; if(x&lt;0) -1*x)
  
  
  
  
  
  Solution.scala:2: error: type mismatch;
   found   : List[AnyVal]
   required: List[Int]
  def f(arr:List[Int]):List[Int] = arr.map((x: Int) =&gt; if(x&lt;0) -1*x)
                                          ^
  </code></pre>