Slide 15
Slide 15 text
Other Powerful HOF’s examples
Sum
(1 to 1000).reduceLeft( _ + _ )
(1 to 1000).sum
Partition filter
val (passed, failed) = List(49, 58, 88, 90) partition ( _ > 60 )
min
List(14, 35, -7, 46, 98).min
max
List(14, 35, -7, 46, 98).max
Imperative iteration
(1 to 10) foreach (println)
Parallel Collections
(1 to 10).par foreach(_ => println(Thread.currentThread.getName))