Skip to content

Instantly share code, notes, and snippets.

@kretes
Created February 5, 2014 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kretes/8828959 to your computer and use it in GitHub Desktop.
Save kretes/8828959 to your computer and use it in GitHub Desktop.
package pl.japila.scalania.s99
object S99_P05 {
def reverse[T](ts: Seq[T]): Seq[T] = {
reverseAsList(ts.toList)
}
def reverseAsList[T](ts: List[T]): List[T] = {
ts match {
case List() => List()
case _ => ts.last :: reverseAsList(ts.dropRight(1))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment