in reply to Re: how to avoid using index of array
in thread how to avoid using index of array
I knew that it would be (and glad that it was) just a matter of time before you posted a Perl6 and zip operator solution.
I've been trying to figure out how to do that (before you made your post) using Perl 6 and the zip operator. Thanks for posting an example. For some reason I was expecting that the syntax should look more like this:
for( @male Z @female )->[$m,$f] { # .... }
But apparently not. ;) Also, how would you push a stringified concatenation onto a new array? In Perl5 either of these would do WIM:
my @married; foreach( 0 .. $#male ) { push @married, "$male[$_] $female[$_]"; } # OR ..... my @married = map { "$male[$_] $female[$_]" } 0 .. $#male; # OR with List::MoreUtils::pairwise my @married = pairwise{ "$a $b" } @male, @female;
...or you could forgo interpolation and use the (.) dot operator.
I've been puzzling over a Perl6-ish, Zip-operator-ish way to do the same.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to avoid using index of array
by moritz (Cardinal) on Nov 13, 2011 at 08:27 UTC |