The first fills unused subarray elements with undef.
This gets rid of the undefs.
sub groups_of_n { my $n = shift; return map { [ grep {defined} @$_ ] } map { [ @_ [$_ * $n .. $_ * $n + $n -1 ]] } 0 .. $#_ / $n; }
Cheers,
JohnGG
In reply to Re^2: Syntactically cool list of lists
by johngg
in thread Syntactically cool list of lists
by jettero
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |