In Kotlin, is there a functional way to traverse through a List<T> getting a Pair<T,T> that reflect the current/next element.
E.g. - the imperative approach would be something like
for (index in 0 until list.size-1) {
val current = list[index]
val next = list[index + 1]
//do calculations on current/next.
}
Something like list.forEachPaired { it: Pair<String,String?> ->//do something }