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

Re: On the rejected additions to List::Util

by moritz (Cardinal)
on Apr 29, 2009 at 07:36 UTC ( [id://760824]=note: print w/replies, xml ) Need Help??


in reply to On the rejected additions to List::Util

Just let me say that the any() implementation in List::MoreUtils is more general than the one described in the list of rejected functions.

Specifically in List::MoreUtils it takes a block, and evaluates that for every list item, and returns true if the block returned true once. The one described in List::Util just gives true when any of the list items is true, so

List::MoreUtils::any is roughly like List::Util::proposed_any map BLOCK LIST

except that it's optimized.

That's not as trivial (ok, it's only slightly more complicated) as Graham puts it, which is why I never understood his point.

Replies are listed 'Best First'.
Re^2: On the rejected additions to List::Util
by Prof Vince (Friar) on May 08, 2009 at 07:44 UTC
    List::MoreUtils::any() also stops looking as soon as one of the blocks returned true. Check :

    perl -MList::MoreUtils=any -E 'any { say $_; $_ < 5 ? 0 : 1 } 1 .. 10'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-28 14:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found