Skip to content

Instantly share code, notes, and snippets.

@frgomes
Last active August 29, 2015 14:16
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 frgomes/5eb9005b07ec86417183 to your computer and use it in GitHub Desktop.
Save frgomes/5eb9005b07ec86417183 to your computer and use it in GitHub Desktop.
Scala - Sample usage of foldLeft
val init="aaa"
val s1 = List("b", "c", "d").foldLeft(init) { (acc, item) => acc + item }
println(s1) // prints: aaabcd
val s2 = ( "aaa" /: List("b", "c", "d")) { (acc, item) => acc + item }
println(s2) // prints: aaabcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment