Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Mini-Tutorial: Working with Odd/Even Elements

by Anonymous Monk
on Jul 09, 2009 at 18:44 UTC ( [id://778654]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $t = 0;
    grep { $t^=1 } LIST
    
  2. or download this
    my $t = 0; #even elements
    #my $t= 1; #odd elements
    grep { $t++ % 2 } LIST
    
  3. or download this
    my $t = 0;
    map { $t++ %2 ? $_ : () } LIST
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-18 04:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found