Skip to content

Instantly share code, notes, and snippets.

@nsfyn55
Created June 18, 2012 18:21
Show Gist options
  • Save nsfyn55/2949814 to your computer and use it in GitHub Desktop.
Save nsfyn55/2949814 to your computer and use it in GitHub Desktop.
Reverse Singly Linked List
def reverse[T](xs: List[T]): List[T] = xs match {
case List() => List()
case x :: xs1 => reverse(xs1) ::: List(x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment