Created
May 28, 2011 17:30
-
-
Save oluies/997050 to your computer and use it in GitHub Desktop.
reverseStr
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
| println(List(1,2,3).foldLeft(0)((b,a) => b+a)) | |
| println(List(1,2,3).reduceLeft((b,a) => b+a)) | |
| // reverse a string with foldleft | |
| def reverseStr(s: String) = (s.toList.foldLeft(List[Char]()) {(xs, x) => {x :: xs}}).mkString | |
| println(reverseStr("hejsan")) | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
6
6
nasjeh