public inline fun <T> Iterable<T>.partition(predicate: (T) -> Boolean):
Pair<List<T>, List<T>> {
val first = ArrayList<T>()
val second = ArrayList<T>()
for (element in this) {
if (predicate(element)) {
first.add(element)
} else {
second.add(element)
}
}
return Pair(first, second)
}
val list = listOf(1, 2, 3, 4, 5)
println(list.partition{ it % 2 == 0 }) // [2, 4], [1, 3, 5]