W3cubDocs

/Kotlin

foldRightIndexed

inline fun <T, R> List<T>.foldRightIndexed(
    initial: R, 
    operation: (index: Int, T, acc: R) -> R
): R

Accumulates value starting with initial value and applying operation from right to left to each element with its index in the original list and current accumulator value.

Parameters

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

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

Accumulates value starting with initial value and applying operation from right to left to each element with its index in the original array and current accumulator value.

Parameters

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

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/fold-right-indexed.html