foldIndexed

abstract fun <R> foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R

对序列中的所有元素应用指定的累积操作,并返回累积结果,并提供元素的索引。

此函数类似于 Kotlin 标准库中的 foldIndexed 函数。

参考 kotlin.sequences.foldIndexed

Return

累积结果。

Parameters

initial

累积操作的初始值。

operation

一个函数,它接收元素的索引、累积值和序列的当前元素作为参数,并返回新的累积值。