Logo

Programming-Idioms

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

Idiom #26 Create a 2-dimensional array

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

(for [i (range 1 (inc m))]
  (for [j (range 1 (inc n))]
    (* i j)))

Creates an m by n matrix filled with the multiplication table for 1 to m by 1 to n (inclusive)
X : array (1 .. M, 1 .. N) of Float := (others => (others => 1.0));

New implementation...