You are viewing a single comment's thread. Return to all comments →
def f(arr:List[Int]):List[Int] = { import scala.annotation.tailrec @tailrec def loop(arr: List[Int], acc: List[Int]): List[Int] = arr match { case x :: xs => loop(xs, x :: acc) case _ => acc } loop(arr, Nil) }
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse a List
You are viewing a single comment's thread. Return to all comments →