Created
April 25, 2016 11:24
-
-
Save Korilakkuma/a3eba57eb333bfe84d3c614b666ba2bf to your computer and use it in GitHub Desktop.
Reverse method by foldLeft
This file contains hidden or 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
def reverse[T](list: List[T]): List[T] = list.foldLeft(Nil: List[T])((a, b) => b :: a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment