Logo

Programming-Idioms

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

Idiom #26 Create a 2-dimensional array

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

X = [{R * 1.0, C * 1.0} || R <- lists:seq(1, M), C <- lists:seq(1, N)].

You don't declare and initialize in Erlang. This is the closest thing.
X : array (1 .. M, 1 .. N) of Float := (others => (others => 1.0));

New implementation...