怎样理解如下的结果?
scala> val list = List(1,2,3,4,5)
scala> list.reduceRight(_ - _)
res26: Int = 3
执行过程如下:
(1 - ( 2 - ( 3 - ( 4 - 5 ))))
官方文档说明:
op(x_1, op(x_2, ..., op(x_{n-1}, x_n)...))
where x1, ..., xn are the elements of this mutable indexed sequence.
文档地址:
https://www.scala-lang.org/api/current/scala/Array.html#reduceRight[B>:A](op:(A,B)=>B):B