Logo

Programming-Idioms

History of Idiom 27 > diff from v22 to v23

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

Version 22

2016-03-02, 14:27:10

Version 23

2016-04-05, 04:42:46

Idiom #27 Create a 3-dimensional array

Declare and initialize a 3D array x, having dimensions boundaries m, n, p, and containing real numbers.

Idiom #27 Create a 3-dimensional array

Declare and initialize a 3D array x, having dimensions boundaries m, n, p, and containing real numbers.

Code
X = array(M, N, P).

-spec array(pos_integer(), pos_integer(), pos_integer()) -> [[[float()]]].
array(M, N, P) -> [array(M, N)  || _ <- lists:seq(1, P)].
array(M, N) -> [array(M) || _ <- lists:seq(1, N)].
array(M) -> [rand:uniform() || _ <-lists:seq(1, M)].
Demo URL
http://tryerl.seriyps.ru/#id=78f3