A Perl 6 solution, because I can't resist:
my @swapped = (1..8).map: { $^b, $^a };
In reply to Re: Switch the odd/even elements of an array
by moritz
in thread Switch the odd/even elements of an array
by jaredor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |