in reply to Re^2: Sub-setting an Array
in thread Sub-setting an Array
That's an odd way to get subsets of three elements. You can't grab them three at a time and maybe the end one has fewer than three elements? As in the example in the docs for splice?
sub nary_print { my $n = shift; while (my @next_n = splice @_, 0, $n) { say join q{ -- }, @next_n; } } nary_print(3, qw(a b c d e f g h)); # prints: # a -- b -- c # d -- e -- f # g -- h
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Sub-setting an Array
by Anonymous Monk on Sep 05, 2015 at 00:45 UTC | |
by AnomalousMonk (Archbishop) on Sep 05, 2015 at 03:23 UTC | |
by 1nickt (Canon) on Sep 05, 2015 at 01:05 UTC | |
by Anonymous Monk on Sep 05, 2015 at 01:17 UTC | |
by 1nickt (Canon) on Sep 05, 2015 at 01:27 UTC | |
by kgherman (Novice) on Sep 05, 2015 at 01:33 UTC | |
by Anonymous Monk on Sep 05, 2015 at 02:27 UTC | |
|
Re^4: Sub-setting an Array
by Anonymous Monk on Sep 05, 2015 at 00:43 UTC |