List ProductByFoldLeft
object ProductByFoldLeft { def product(as: List[Double]): Double = FoldLeft.foldLeft(as, 1.0)(_ * _) def main(args: Array[String]): Unit = { println(product(List(1.0, 2, 3, 4, 5))) println(product(List(1.0))) println(product(List(1, 2, 0.0, 4, 5))) } }
120.0 1.0 0.0
posted on 2016-04-19 22:18 JonkeyGuan 阅读(210) 评论(0) 收藏 举报
浙公网安备 33010602011771号