Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^6: Smartmatch alternatives

by LanX (Bishop)
on Dec 17, 2013 at 22:57 UTC ( #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
Node Status?
node history
Node Type: note [id://1067543]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-12-18 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (495 votes). Check out past polls.

    Notices?