Logo

Programming-Idioms

History of Idiom 26 > diff from v51 to v52

Edit summary for version 52 by Alexander:
[Clojure] Use i and j per diagram

Version 51

2019-02-16, 07:58:10

Version 52

2019-02-16, 07:58:56

Idiom #26 Create a 2-dimensional array

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

Illustration

Idiom #26 Create a 2-dimensional array

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

Illustration
Code
(for [r (range 1 (inc m))]
  (for [c (range 1 (inc n))]
    (* r c)))
Code
(for [i (range 1 (inc m))]
  (for [j (range 1 (inc n))]
    (* i j)))
Comments bubble
Creates an m by n matrix filled with the multiplication table for 1 to m by 1 to n (inclusive)
Comments bubble
Creates an m by n matrix filled with the multiplication table for 1 to m by 1 to n (inclusive)