in reply to Re: Printing from three arrays
in thread Printing from three arrays
Nested loops become unwieldy when you have many arrays. With a suitable module it does not matter how many dimension the input has:
Bonus:
There are numerous alternatives: https://metacpan.org/search?q=cartesian+productuse 5.010; use Set::Scalar qw(); my $iter = Set::Scalar->cartesian_product_iterator( map { Set::Scalar->new(@$_) } [1, 2, 3], [qw/a b c/], [qw/I II III/], ); while (my @m = $iter->()) { say "@m"; }
Bonus:
use v6; .say for cross (1, 2, 3), <a b c>, <I II III>
|
---|
In Section
Seekers of Perl Wisdom