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

fold

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

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

Parameters

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

initial - B: initial value from which the folding will be performed

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

- type of the values stored by the iterable

- type of the return value

Return
B: result of the folding