Created
April 1, 2016 05:55
-
-
Save hn5092/a6f60cfb42c626fbd516485954bc73d3 to your computer and use it in GitHub Desktop.
reduce is args is head,s fold
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
object common extends App { | |
val a = "s" | |
println(s"wo kao $a") | |
case class Foo(val name: String, val age: Int, val sex: Symbol) | |
val fooList = Foo("Hugh Jass", 25, 'male) :: | |
Foo("Biggus Dickus", 43, 'male) :: | |
Foo("Incontinentia Buttocks", 37, 'female) :: | |
Nil | |
println(fooList) | |
val stringList = fooList.foldLeft(List[String]()) { (z, f) => | |
val title = f.sex match { | |
case 'male => "Mr." | |
case 'female => "Ms." | |
} | |
z :+ s"$title ${f.name}, ${f.age}" | |
} | |
println(stringList) | |
println(stringList(0)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment