invoke
Create a copy of the parameter using the copyOf
member function.
Return
The copy (from copyOf), depending on the type this may be the same object as the original.
Parameters
original
The matrix to create a copy of
A matrix that is contains the given "initial" value. The implementation is immutable.
Return
The resulting matrix.
Parameters
width
The width of the matrix
height
The height of the matrix
init Value
The value for each cell in the matrix.
open inline operator override fun <T> invoke(width: Int, height: Int, init: (Int, Int) -> T): Matrix<T>
A simple array-like matrix that contains the values given by the function. The values are assigned at construction.
val multiplicationTable = Matrix(12, 12) { x, y ->
(x * y).toString()
}
Content copied to clipboard
Return
The resulting matrix (storing all values)
Parameters
width
The width of the matrix
height
The height of the matrix
init
Function that allows setting each cell in the matrix. Its parameters are the x and y coordinates.