Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Expression form of map or grep

by Lady_Aleena (Priest)
on Jul 10, 2020 at 19:47 UTC ( [id://11119158]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @colors = qw(red yellow green cyan blue magenta);
    my @grey_scale = qw(white grey black);
    
    my @list = map "$_ beads", @colors, @grey_scale;
    
  2. or download this
    my @list = map( "$_ beads", @colors ), @grey_scale;
    
  3. or download this
    my @list = ( map { "$_ beads" } @colors ), @grey_scale;
    
  4. or download this
    sub make_beads {
      my $color = shift;
    ...
    }
    
    my @list = map( make_beads($_), @colors), @grey_scale;
    
  5. or download this
    my @list = (
      map  { make_beads($_} }
    ...
      grep { <something> }
      @colors
    ), @grey_scale;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://11119158]
Approved by tobyink
Front-paged by davies
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-03-28 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found