scala> // /: or foldLeft() #361, 363 scala> def sum(xs: List[Int]): Int = { | (7 /: xs) (_ + _) | } sum: (xs: List[Int])Int scala> scala> val data = List(1, 2, 3) data: List[Int] = List(1, 2, 3) scala> sum(data) res39: Int = 13 scala> scala> val data = List(1, 2, 3) data: List[Int] = List(1, 2, 3) scala> data.foldLeft(7)(_ + _) res40: Int = 13 scala> scala> // :\ or foldRight() #361, 363 scala> def sum(xs: List[Int]): Int = { | (xs :\ 7) (_ + _) | } sum: (xs: List[Int])Int scala> scala> val data = List(1, 2, 3) data: List[Int] = List(1, 2, 3) scala> sum(data) res41: Int = 13 scala> scala> val data = List(1, 2, 3) data: List[Int] = List(1, 2, 3) scala> data.foldRight(7)(_ + _) res42: Int = 13 scala> scala> scala> // Note/Beware : foldLeft() & foldRight() has difference scala> // in terms of efficiency #364 scala> // Best Practice : Is intuitive to use foldLeft() instead of scala> // Symbol /: