Logo

Programming-Idioms

History of Idiom 27 > diff from v23 to v24

Edit summary for version 24 by :
[Erlang] needed extra space for syntax highlight

Version 23

2016-04-05, 04:42:46

Version 24

2016-04-05, 04:44:19

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)].
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
Demo URL
http://tryerl.seriyps.ru/#id=78f3