foldRight

inline fun <T, R> Array<out T>.foldRight(initial: R, operation: (T, acc: R) -> R): R(source)
inline fun <R> ByteArray.foldRight(initial: R, operation: (Byte, acc: R) -> R): R(source)
inline fun <R> ShortArray.foldRight(initial: R, operation: (Short, acc: R) -> R): R(source)
inline fun <R> IntArray.foldRight(initial: R, operation: (Int, acc: R) -> R): R(source)
inline fun <R> LongArray.foldRight(initial: R, operation: (Long, acc: R) -> R): R(source)
inline fun <R> FloatArray.foldRight(initial: R, operation: (Float, acc: R) -> R): R(source)
inline fun <R> DoubleArray.foldRight(initial: R, operation: (Double, acc: R) -> R): R(source)
inline fun <R> BooleanArray.foldRight(initial: R, operation: (Boolean, acc: R) -> R): R(source)
inline fun <R> CharArray.foldRight(initial: R, operation: (Char, acc: R) -> R): R(source)

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

Returns the specified initial value if the array is empty.

Since Kotlin

1.0

Parameters

operation

function that takes an element and current accumulator value, and calculates the next accumulator value.


inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, acc: R) -> R): R(source)

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

Returns the specified initial value if the list is empty.

Since Kotlin

1.0

Parameters

operation

function that takes an element and current accumulator value, and calculates the next accumulator value.