``` fun <T> List<T>.scan(fn: (...
# rx
a
Copy code
fun <T> List<T>.scan(fn: (T, T) -> T): List<T> {
            return if (this.isEmpty()) this
            else this.drop(1).fold(listOf(this.first()), { acc, item ->
                acc.plus(fn(acc.last(), item))
            })
        }

        println((1..5).toList().scan { x, y -> x + y })
I got one solution with fold, but you might be able to figure out a better approach.