Skip to content

Instantly share code, notes, and snippets.

@dwins
Created March 4, 2011 14:27
Show Gist options
  • Save dwins/854682 to your computer and use it in GitHub Desktop.
Save dwins/854682 to your computer and use it in GitHub Desktop.
def reverse[A](xs: List[A]): List[A] = {
def reverse0(xs: List[A], accum: List[A]): List[A] =
xs match {
case Nil => accum
case h :: t => reverse0(t, h :: accum)
}
reverse0(xs, Nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment