Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: All Combinations of three arrays.

by halley (Prior)
on Aug 26, 2005 at 16:40 UTC ( #486917=note: print w/replies, xml ) Need Help??


in reply to All Combinations of three arrays.

Normally I would try to figure this out, but I'm in a hurry and so i have to ask for assistance.

You're a long-standing monk here; is this the attitude that you like to find at the front gate every day? It probably took you more time to type up your example than it would to code the solution.

For the fixed-number-of-columns case, just nest loops.

my $struct = [ [], [], [] ]; for my $A (@{$struct->[0]}) { for my $B (@{$struct->[1]}) { for my $C (@{$struct->[2]}) { ... } } }

For the variable-number-of-columns case, a recursive solution or a stack iteration would work.

--
[ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://486917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2020-05-25 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (143 votes). Check out past polls.

    Notices?