in reply to Re: Re: Quantum::Superpositions prob
in thread Quantum::Superpositions prob
Now if for some reason order is important to you, you can reverse the array/hash for the stack.my @visited = (1 .. 5); my %unvisited = map { $_ => undef } 1 .. 9; while ( %unvisited ) { delete @{unvisited}{@visited}; for ( keys %unvisited ) { visit( $_, \%unvisited ); # Adds routers to %unvisited push @visited , $_; } }
I hope these solutions are helpful.my %visited = map { $_ => undef } (1 .. 4); my @unvisited = (1 .. 9); while ( @unvisited ) { my $router = shift @unvisited; next if exists $visited{$router}; visit ( $router, \@unvisited ); # Adds routers to @unvisited $visited{$router} = undef; }
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Quantum::Superpositions prob
by tommycahir (Acolyte) on Mar 25, 2004 at 18:50 UTC |