in reply to Unfolding a nDeep structure
Update: Just noticed that you wanted to know how to initialize this big structure to zeroes. The Dive sub doesn't autovivify, but DiveVal does:# (untested) use Data::Diver qw[Dive DiveVal]; use Algorithm::Loops 'NestedLoops'; NestedLoops( [ ( [0..$dimension-1] ) x $depth ], sub { my @indices = @_; my $val = Dive( \@multi_dimensional_array, @indices ); ## do something with $val. say, push it to an array } );
## initialization my @multi_dimensional_array; NestedLoops( [ ( [0..$dimension-1] ) x $depth ], sub { DiveVal( \@multi_dimensional_array, @_ ) = 0; } );
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unfolding a nDeep structure
by FFRANK (Beadle) on Jul 05, 2007 at 21:23 UTC | |
by blokhead (Monsignor) on Jul 05, 2007 at 23:13 UTC |