History of Idiom 26 > diff from v40 to v41
Edit summary for version 41 by programming-idioms.org:
[Rust] Use M and N. No sample values. No main func. +DemoURL
[Rust] Use M and N. No sample values. No main func. +DemoURL
↷
Version 40
2018-05-09, 20:32:38
Version 41
2018-05-10, 09:31:28
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
fn main() {
const M: usize = 4;
const N: usize = 4;
let x: [[f64; 4]; 4] = [[ 0.0, 1.0, 2.0, 3.0],
[ 4.0, 5.0, 6.0, 7.0],
[ 8.0, 9.0, 10.0, 11.0],
[12.0, 13.0, 14.0, 15.0]];
assert_eq!(x[0][0], 0.0);
assert_eq!(x[0][3], 3.0);
assert_eq!(x[3][0], 12.0);
println!("the value at 2,2 should be 10.0, {}", x[2][2]);
}
Comments bubble
Elements have type f64