Logo

Programming-Idioms

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

Idiom #26 Create a 2-dimensional array

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

let mut x = vec![vec![0.0f64; N]; M];
let mut x = [[0.0; N] ; M];

This works only when M and N are constant.
Elements have type f64
X : array (1 .. M, 1 .. N) of Float := (others => (others => 1.0));

New implementation...