@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.
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
IllegalArgumentException
- if the passed iterable is empty
Return
A: result of the reduction