val a = List(1, 2, 3, 4)
def f(x: Int): Int = x * 2
println( a.map(f) )
println( a.map(_ * 2) )
List(2, 4, 6, 8) List(2, 4, 6, 8)
a: List[Int] = List(1, 2, 3, 4) defined function f
def g(left: Int, right: Int): Int = left + right
println( a.reduce(g) )
def h(left: Int, right: Int): Int = left * right
println( a.reduce(h) )
10 24
defined function g defined function h