gaetan
03/05/2017, 9:29 AMfun <T> List<T>.batch(batchSize:Int): List<List<T>> {
var startIndex = 0
val ret = mutableListOf<List<T>>()
while (startIndex < this.size){
ret.add(subList(startIndex, (startIndex + batchSize ).coerceAtMost(size)))
startIndex += batchSize
}
return ret
}