Logo

Programming-Idioms

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

Idiom #26 Create a 2-dimensional array

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

(build-list m (lambda (x)
                (build-list n (lambda (y) 0))))

The (lambda (y) 0) isn't strictly necessary, it just initializes the values in the matrix to 0.
X : array (1 .. M, 1 .. N) of Float := (others => (others => 1.0));

New implementation...