Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

N-Dimensional Arrays on the fly

by qumsieh (Scribe)
on Aug 19, 2004 at 23:44 UTC ( [id://384495]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $dim  = 3;
    my @size = (4, 5, 6);
    ...
    $str .= " = 0;\n";
    
    $str .= "  " x ($dim - $_) . "}\n" for 1 .. $dim;
    
  2. or download this
    for my $a (0 .. 4 - 1) {
      for my $b (0 .. 5 - 1) {
    ...
        }
      }
    }
    
  3. or download this
      my $i = 0;
      my $sub = 'sub { $array' .
                join '' => map {'[$_[' . $i++ . ']]'} 1 .. $dim;
      $sub .= ' = $_[-1] }' . "\n";
    
  4. or download this
    sub { $array[$_[0]][$_[1]][$_[2]] = $_[-1] }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://384495]
Approved by blokhead
Front-paged by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found