Here is two implemented function that reverse the List[Int]:
def reverse1(remaining: List[Int]): List[Int] =
remaining match
case Nil => Nil
case head :: tail => reverse1(tail) :+ head
def reverse2(reversed: List[Int], remaining: List[Int]): List[Int] =
remaining match
case Nil => reversed
case head :: tail => reverse2(head :: reversed, tail)
Which function is tail-recursive?