Prime triangle: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: splice out 'undef' list element) |
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: document the why the 'splice' sometimes needed) |
||
Line 792: | Line 792: | ||
my $nope = 0; |
my $nope = 0; |
||
for my $o (permutations [@odd_nums]) { |
for my $o (permutations [@odd_nums]) { |
||
my @list = (zip(@$e, @$o), $n); |
my @list = (zip(@$e, @$o), $n); # 'zip' makes a list with a gap if more evens than odds |
||
splice @list, -2, -1 if not defined $list[-2]; |
splice @list, -2, -1 if not defined $list[-2]; # in which case splice out 'undef' in next-to-last position |
||
my $it = slideatatime(1, 2, @list); |
my $it = slideatatime(1, 2, @list); |
||
while ( my @rr = $it->() ) { |
while ( my @rr = $it->() ) { |