Kotlin Fold
//sum function with fold
fun main() {
val list = listOf(1, 2, 3, 4, 5)
val result = list.fold(0) { acc, next -> acc + next }
println(result) // 15
}
Ceadeus