I want to make a function in scala that uses "match ... case" to double the values of a list.
For example:
doubleList(List(2,1,4,5)) //> res0: List[Int] = List(4, 2, 8, 10) I wrote this function:
def doubleList(xs: List[Int]): List[Int] = xs match { case y :: ys => y * 2; doubleList(ys); case Nil => xs; } But I get an empty list as the result:
//> res0: List[Int] = List() Can anyone teel me what am I doing wrong?
map(_ * 2)?