Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Expression form of map or grep

by Lady_Aleena (Curate)
on Jul 10, 2020 at 19:47 UTC ( #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
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? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2020-11-01 01:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (291 votes). Check out past polls.

    Notices?