Logo

Programming-Idioms

History of Idiom 26 > diff from v36 to v37

Edit summary for version 37 by Aquamo:
New Rust implementation by user [Aquamo]

Version 36

2018-05-08, 00:39:09

Version 37

2018-05-09, 01:34:05

Idiom #26 Create a 2-dimensional array

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

Illustration

Idiom #26 Create a 2-dimensional array

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

Illustration
Code
fn main() {
  let a: [[i32; 4]; 4] = [[ 0,  1,  2,  3],
                          [ 4,  5,  6,  7],
                          [ 8,  9, 10, 11],
                          [12, 13, 14, 15]];

  assert_eq!(a[0][0], 0);
  assert_eq!(a[0][3], 3);
  assert_eq!(a[3][0], 12);

  println!("the value at 2,2 should be 10, {}", a[2][2]);
}