@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.
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
Return
B: result of the folding