Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: The fastest way of searching a certain element in an array

by ccn (Vicar)
on Apr 15, 2004 at 22:56 UTC ( #345576=note: print w/replies, xml ) Need Help??


in reply to Re: The fastest way of searching a certain element in an array
in thread The fastest way of searching a certain element in an array

Hmm..., surely it is not the fastest. Here is it's code:
sub first (&@) { my $code = shift; foreach (@_) { return $_ if &{$code}(); } undef; }
You can see, it is similar to my for_block which was benchmarked.
  • Comment on Re: Re: The fastest way of searching a certain element in an array
  • Download Code

Replies are listed 'Best First'.
Re^3: The fastest way of searching a certain element in an array
by Limbic~Region (Chancellor) on Jan 14, 2005 at 19:38 UTC
    ccn,
    Here is it's code:

    Well that depends. As I indicated in Getting Matching Items From An Array, List::Util falls back to pure perl (which has obvious inefficiencies) only if the XS version is unavailable. Which version of 'first' did you use in your benchmarks?

    Cheers - L~R

      I benchmarked 'first' with XS loaded. To make shure that XS was loaded I've inserted some alerting printouts in pure perl version of the 'first'.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://345576]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2016-12-03 14:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.