I have the following list :
INPUT :: 4 5 8 -11 9 5 -7 4 6 -6 -8 -11 80 -32 -56 -15 5 -49
OUTPUT :: 4 9 17 6 15 20 13 17 23 17 9 -2 78 46 -10 -25 -20 -69
I need to calculate cumulative sum - List meaning
T(n) = T(n) + T(n-1) for n >0;
and
T(0) = T(0)
I want to calculate that with Java stream API so that I can implement it with Spark for big data calculation. I am naive in Java Streams I have tried several expressions bt none of them is working the equivalent stuctured code should be like :
int[] numbers = {4, 5, 8, -11, 9, 5, -7, 4, 6,-6, -8, -11, 80, -32, -56, -15, 5, -49};
int temp = 0;
for (int i = 0 ; i < numbers.length ; i++) {
temp = temp + numbers[i];
numbers[i] = temp;
}