Selasa, 11 Januari 2011

reduceLeft

$ cat max.scala

val myList = List("OK", "foobar", "All I can do is to finishi it", "The touch")
println( myList )

val longest = myList.reduceLeft(
(a,b) => if (a.length > b.length ) a else b
)
println( longest )


$ scala max.scala
List(OK, foobar, All I can do is to finishi it, The touch)
All I can do is to finishi it

Tidak ada komentar:

Poskan Komentar