Created
February 5, 2014 17:27
-
-
Save kretes/8828959 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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