commonMain.dev.inmo.micro_utils.matrix.MatrixBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micro_utils.matrix Show documentation
Show all versions of micro_utils.matrix Show documentation
It is set of projects with micro tools for avoiding of routines coding
package dev.inmo.micro_utils.matrix
open class MatrixBuilder {
private val mutMatrix: MutableList> = ArrayList()
val matrix: Matrix
get() = mutMatrix
fun row(t: List) = mutMatrix.add(t)
fun add(t: List) = mutMatrix.add(t)
operator fun List.unaryPlus() = row(this)
operator fun plus(t: List) = add(t)
operator fun T.unaryPlus() = add(listOf(this))
}
fun MatrixBuilder.row(block: RowBuilder.() -> Unit) = +RowBuilder().also(block).row
fun MatrixBuilder.row(vararg elements: T) = +elements.toList()