Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^6: Smartmatch alternatives

by LanX (Saint)
on Dec 17, 2013 at 22:57 UTC ( [id://1067543]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      DB<25> sub first (&@) { my $code=shift; grep {return $_ if &$code} @
    +_ }
    
    ...
    
      DB<30> any { $_ >5 } 1..10
     => 1
    
  2. or download this
      DB<40> sub position (&@) { my $code=shift; my $idx=-1; grep {++$idx;
    + return $idx if &$code} @_ ; ()}
    
      DB<41> position { !$_ } 1..10,undef,11..20
     => 10
    
  3. or download this
      DB<53> sub first (&@) { my $code=shift; &$code and return $_ for @_ 
    +; ()}
    
      DB<54> sub any (&@) { my $code=shift; &$code and return 1 for @_ ; (
    +)}
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-25 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found