foldRight

Common
JVM
JS
Native
1.0
inline fun <T, R> Array<out T>.foldRight(
    initial: R,
    operation: (T, acc: R) -> R
): R
inline fun <R> ByteArray.foldRight(
    initial: R,
    operation: (Byte, acc: R) -> R
): R
inline fun <R> ShortArray.foldRight(
    initial: R,
    operation: (Short, acc: R) -> R
): R
inline fun <R> IntArray.foldRight(
    initial: R,
    operation: (Int, acc: R) -> R
): R
inline fun <R> LongArray.foldRight(
    initial: R,
    operation: (Long, acc: R) -> R
): R
inline fun <R> FloatArray.foldRight(
    initial: R,
    operation: (Float, acc: R) -> R
): R
inline fun <R> DoubleArray.foldRight(
    initial: R,
    operation: (Double, acc: R) -> R
): R
inline fun <R> BooleanArray.foldRight(
    initial: R,
    operation: (Boolean, acc: R) -> R
): R
inline fun <R> CharArray.foldRight(
    initial: R,
    operation: (Char, acc: R) -> R
): R
@ExperimentalUnsignedTypes inline fun <R> UIntArray.foldRight(
    initial: R,
    operation: (UInt, acc: R) -> R
): R
@ExperimentalUnsignedTypes inline fun <R> ULongArray.foldRight(
    initial: R,
    operation: (ULong, acc: R) -> R
): R
@ExperimentalUnsignedTypes inline fun <R> UByteArray.foldRight(
    initial: R,
    operation: (UByte, acc: R) -> R
): R
@ExperimentalUnsignedTypes inline fun <R> UShortArray.foldRight(
    initial: R,
    operation: (UShort, acc: R) -> R
): R

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.

Parameters

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

Common
JVM
JS
Native
1.0
inline fun <T, R> List<T>.foldRight(
    initial: R,
    operation: (T, acc: R) -> R
): R

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.

Parameters

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