Logo

Programming-Idioms

History of Idiom 27 > diff from v29 to v30

Edit summary for version 30 by dmaestro:
New Perl implementation by user [dmaestro]

Version 29

2018-08-05, 12:27:35

Version 30

2018-08-18, 20:39:49

Idiom #27 Create a 3-dimensional array

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

Illustration

Idiom #27 Create a 3-dimensional array

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

Illustration
Code
my $array3d = [
    [ [ 1, 0, 1 ],
      [ 0, 0, 0 ],
      [ 1, 0, 1 ] ],
    [ [ 0, 0, 0 ],
      [ 0, 2, 0 ],
      [ 0, 0, 0 ] ],
    [ [ 3, 0, 3, ],
      [ 0, 0, 0, ],
      [ 3, 0, 3, ] ]
];
Comments bubble
Array variables are only one-dimensional, but lists-of-lists using array references can represent multi-dimensional arrays.
Doc URL
https://perldoc.perl.org/perllol.html