Partition indexed
fun <T> List<T>.partitionIndexed(predicate: (Int, T) -> Boolean): Pair<List<T>, List<T>> {
val first = mutableListOf<T>()
val second = mutableListOf<T>()
for ((index, element) in this.withIndex()) {
if (predicate(index, element)) {
first.add(element)
} else {
second.add(element)
}
}
return Pair(first, second)
}