Logo

Programming-Idioms

History of Idiom 26 > diff from v19 to v20

Edit summary for version 20 by :
New Erlang implementation by user [elbrujohalcon]

Version 19

2016-01-07, 14:12:30

Version 20

2016-01-26, 02:11:57

Idiom #26 Create a 2-dimensional array

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

Idiom #26 Create a 2-dimensional array

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

Code
X = [{R * 1.0, C * 1.0} || R <- lists:seq(1, M), C <- lists:seq(1, N)].
Comments bubble
You don't declare_ and initialize_ in Erlang. This is the closest thing.
Doc URL
http://learnyousomeerlang.com/starting-out-for-real#list-comprehensions
Demo URL
http://tryerl.seriyps.ru/#id=02f3