foldRight 

To understand the concept of the foldRight function, we'll use addition as an operation. The foldRight function adds all the elements of the list and returns the result. Just like the fold function, it takes an integer parameter and lambda expression. The difference is that the foldRight function starts executing at the end of the list:

result = numbers.foldRight(0){i,j -> i + j}
println("From End : add all elements of the list " + result)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.218.226