in reply to Processing arrays 2 elements at a time (TIMTOWTDI)

Here's a somewhat more efficient splicer that is almost as fast as the shifter function:

sub s2 { my @r2; while (@_) { push @r2, [ splice @_, 0, 2 ]; } return \@r2; }
This is faster than splicer() because it doesn't have the overhead of assigning the chunks to a temporary array.

By removing the overhead of entering a block on each iteration, it'll be even faster:

sub s2 { my @r2; push @r2, [ splice @_, 0, 2 ] while @_; return \@r2; }
As fast as the unaltered shifter() to be precise (but of course shifter() would still win if it were altered in the same way).

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.