Logo

Programming-Idioms

History of Idiom 26 > diff from v13 to v14

Edit summary for version 14 by :

Version 13

2015-09-04, 20:46:01

Version 14

2015-10-29, 14:05:13

Idiom #26 Create a 2-dimensional array

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

Idiom #26 Create a 2-dimensional array

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

Code
x = [ [ j**(1/i) | j <- [1..n] ] | i <- [1..m] ]
Code
x = [ [ j**(1/i) | j <- [1..n] ] | i <- [1..m] ]
Code
var x = new Array(m);
for (var i = 0; i < m; i++) {
  x[i] = new Array(n);
}
Code
var x = new Array(m);
for (var i = 0; i < m; i++) {
  x[i] = new Array(n);
}
Origin
http://stackoverflow.com/a/24407669/871134
Origin
http://stackoverflow.com/a/24407669/871134
Code
double[][] x = new double[m][n];
Code
double[][] x = new double[m][n];
Comments bubble
Initial values are 0.0
m and n need not be known at compile time
Comments bubble
Initial values are 0.0
m and n need not be known at compile time
Demo URL
http://ideone.com/tWa2Nf
Demo URL
http://ideone.com/tWa2Nf