FFRANK has asked for the wisdom of the Perl Monks concerning the following question:
1) Initialize a nDeep structure with zeros:
2) Do stuff with the structure, add data, etc.#!/usr/bin/perl -w use strict; my $deeepness = 5; my @nDeep = (); my $dimention = 5; for my $deep0 (0..$dimention-1) { for my $deep1 (0..$dimention-1) { for my $deep2 (0..$dimention-1) { for my $deep3 (0..$dimention-1) { for my $deep4 (0..$dimention-1) { $nDeep[$deep0][$deep1][$deep2][$deep3][$deep4] = 0 +; } } } } }
3) Unfold the structure into a 2D array:
I would be interested in this all happening only by specifying a deepness level (my $deepness = 5 in this case).for my $deep0 (0..$dimention-1) { for my $deep1 (0..$dimention-1) { for my $deep2 (0..$dimention-1) { for my $deep3 (0..$dimention-1) { for my $deep4 (0..$dimention-1) { push @{$AoA[$deep0]}, $nDeep[$deep0][$deep1][$deep +2][$deep3][$deep4]; } } } } } for my $row (0..$#AoA) { print "@{$AoA[$row]}\n"; }
Thanks for sharing your enlightening knowledge and your time, always very much appreciated.
Frank
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unfolding a nDeep structure
by blokhead (Monsignor) on Jul 05, 2007 at 15:49 UTC | |
by FFRANK (Beadle) on Jul 05, 2007 at 21:23 UTC | |
by blokhead (Monsignor) on Jul 05, 2007 at 23:13 UTC | |
|
Re: Unfolding a nDeep structure
by ForgotPasswordAgain (Vicar) on Jul 05, 2007 at 15:43 UTC |