Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Switch the odd/even elements of an array

by wind (Priest)
on Mar 04, 2011 at 20:31 UTC ( #891512=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @foo = (1..8);
    
    my @bar = @foo[map {$_ ^ 1} (0..$#foo)];
    
    print "@bar";
    
  2. or download this
    2 1 4 3 6 5 8 7
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://891512]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-11-27 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (188 votes), past polls