xtof
09/07/2023, 6:32 PMscanRight
, a symmetry of scan
, starting by the end of the collection, to be consistent with the availability of fold(Right) and reduce(Right)?
Something like
inline fun <R> List<R>.scanRight(initial: R, operation: (acc: R, Int) -> R): List<R>
So I don't need to use .reversed()
twice to achieve the same with the (left) scan()
that we have like this:
listOf(whatever).reversed().scan(0){acc, e -> operation...}.reversed()
Stephan Schröder
09/07/2023, 9:24 PMAdam S
09/08/2023, 8:19 AMasReversed()
, which should mitigate needing to reverse the list twice
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/as-reversed.htmlxtof
09/09/2023, 5:58 PM