fun <T> Iterable<T>.batch(chunkSize: Int) = this
.mapIndexed { i, item -> i to item }. // create index value pairs
.groupBy { it.first / chunkSize }. // create grouping index
.map { it.value.map { it.second } } // split into different partitions
❤️ 1
m
max.cruz
02/11/2017, 5:07 PM
danneu: Wonderful, thanks. I was thinking in a functional way to split an array in chunks 👍