NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Your reasoning is flawed (Score:1)
Your reasoning is flawed. You are assuming that there is one positive match in the set, and that the set is small. On such a small set you're right any isn't any faster, but superior algorithms rarely show up on small datasets.
If you would test this with a larger dataset, any would come out much better. On my computer, using the list
1..1000and a needle of 500, it is in fact faster. The advantage only gets bigger when the haystack gets bigger.You're right it's not always better, but it is when it matters the most.
Reply to This
Re: (Score:1)
I agree. With such a small set no method is going to take an irritatingly long time. Since you have the program handy could you give it a quick tweak to use a bigger array and re-post the results?
I also agree with autarch that
anyreads better, as a way of signalling programmer intent. I'd probably use theanyfromPerl6::Junctionrather thanList::MoreUtils; any chance you could add that to your testing as well? Thanks!