Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: map grep and sort

by moritz (Cardinal)
on May 25, 2013 at 08:08 UTC ( [id://1035244]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @a = map { transformation($_) } @b;
    # same as
    my @a;
    push @a, tranformation($_) for @b;
    @a
    
  2. or download this
    my @a = grep { condition($_) } @b;
    # same as
    ...
       push @b, $_ if condition($_);
    }
    @a
    
  3. or download this
    my @even = grep $_ % 2 == 0, @numbers;
    my @odd  = map $_ * 2 +1,    @numbers;
    
  4. or download this
    my @numbers = grep /^[0-9]+$/, @words;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-23 18:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found