Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Kotlin

Idiom #26 Create a 2-dimensional array

Declare and initialize a matrix x having m rows and n columns, containing real numbers.

val x = Array(m, { DoubleArray(n) })

The type of x is Array<DoubleArray>. In other words, an array of arrays.
X : array (1 .. M, 1 .. N) of Float := (others => (others => 1.0));

New implementation...