-> IntStream.range(0,10). >> map(xs -> xs*xs). >> filter(xs -> xs % 2 == 0). >> reduce(0, (xs_1, xs_2) -> xs_1 + xs_2) | Expression value is: 120 | assigned to temporary variable $7 of type int
scala> (0 to 9). | map(xs => xs*xs). | filter(_ % 2 == 0). | reduce(_+_) res0: Int = 120
Note: Both Java and Scala have sum methods on these objects which would be equivalent the reduce I used above.
sum
reduce
Is scala popular now?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Java 8+
Scala
Note: Both Java and Scala have
sum
methods on these objects which would be equivalent thereduce
I used above.Is scala popular now?