http://qs321.pair.com?node_id=665265


in reply to Golf/Perlish solution to this problem?

Works with any number of elements, non-destructive:

sub a { @_<2 ? @_ : (pop,shift,&b) } sub b { @_<2 ? @_ : (shift,pop,&a) } print a(1..8), "\n";

Works with a multiple of 4 elements, non-destructive:

sub a { @_ ? (@_[-1,0,1,-2],a(@_[2..$#_-2])) : () } print a(1..8), "\n";

Update: Even shorter,

Works with a multiple of 4 elements, non-destructive:

sub a { @_ ? (pop,shift,shift,pop,&a) : () } print a(1..8), "\n";