fold

inline fun <E : Any, K : Any, R> EntityGrouping<E, *, K>.fold(initialValueSelector: (key: K?, element: E) -> R, operation: (key: K?, accumulator: R, element: E) -> R): Map<K?, R>(source)

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially, 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 provided by initialValueSelector function.

This function is delegated to Grouping.fold, more details can be found in its documentation.


inline fun <E : Any, K : Any, R> EntityGrouping<E, *, K>.fold(initialValue: R, operation: (accumulator: R, element: E) -> R): Map<K?, R>(source)

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially, 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 same initialValue for each group.

This function is delegated to Grouping.fold, more details can be found in its documentation.


inline fun <E : Any, R> EntitySequence<E, *>.fold(initial: R, operation: (acc: R, E) -> R): R(source)

Accumulate value starting with initial value and applying operation from left to right to current accumulator value and each element.

The operation is terminal.