com.github.insanusmokrassar.AutoPostTelegramBot.utils.extensions.Any.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of AutoPostTelegramBot Show documentation
Show all versions of AutoPostTelegramBot Show documentation
It is base library for creating smart bot for simple management of channels posts
package com.github.insanusmokrassar.AutoPostTelegramBot.utils.extensions
import kotlin.math.ceil
inline fun List.toTable(columns: Int): Array> {
val rows = ceil(size.toFloat() / columns).toInt()
return (0 until rows).map {
try {
subList(it * columns, (it + 1) * columns).toTypedArray()
} catch (e: IndexOutOfBoundsException) {
subList(it * columns, size).toTypedArray()
}
}.toTypedArray()
}