reduce
Groups elements from the source sequence by key and applies the reducing operation to the elements of each group sequentially starting from the second element of the group, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the first element of the group.
This function is delegated to Grouping.reduce, more details can be found in its documentation.
Accumulate value starting with the first element and applying operation from left to right to current accumulator value and each element.
Throws an exception if this sequence is empty. If the sequence can be empty in an expected way, please use reduceOrNull instead. It returns null
when its receiver is empty.
The operation function takes the current accumulator value and an element, and calculates the next accumulator value.
The operation is terminal.