sdk-common / com.tomtom.online.sdk.common.functional.collections / Iterables / reduce

reduce

@NonNull static fun <A : Any!> reduce(@NonNull iterable: MutableIterable<A>, @NonNull operator: (A, A) -> A): A

A higher-order function that takes a data structure and a combining operation to combine all the values in the said structure into a single one.

Parameters

iterable - MutableIterable<A>: iterable of values that are going to be reduced into a single value

operator - (A, A) -> A: two argument function that will perform the reduction

- type of the values stored by the iterable

Exceptions

IllegalArgumentException - if the passed iterable is empty

Return
A: result of the reduction