티스토리 뷰

Developer/Java, Kotlin

[Scala] foldLeft

데브포유 2017. 3. 17. 15:45
반응형

val ls = (1 to 100).toList


(0 /: ls) ( _ + _)

(0 /: ls) ((x, y) => x + y)

(0 /: ls) ( (x :Int, y :Int) => x + y)

ls.foldLeft(0)((x :Int, y :Int) => x + y)


모두 5050


반응형