Skip to content

Instantly share code, notes, and snippets.

@oluies
Created May 28, 2011 17:30
Show Gist options
  • Save oluies/997050 to your computer and use it in GitHub Desktop.
Save oluies/997050 to your computer and use it in GitHub Desktop.
reverseStr
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"))
@oluies
Copy link
Author

oluies commented May 28, 2011

6
6
nasjeh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment