Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Short-circuiting a map list.

by Jim (Curate)
on Oct 08, 2011 at 00:24 UTC ( [id://930271]=note: print w/replies, xml ) Need Help??


in reply to Short-circuiting a map list.

Language::Functional::any(), perhaps…

#!perl use strict; use warnings; use feature qw( say ); use Language::Functional qw( any ); sub is_even { $_[0] % 2 == 0 } say any { is_even(shift) } [ 1, 3, 5, 7 ]; # Prints 0 say any { is_even(shift) } [ 2, 4, 6, 8 ]; # Prints 1 exit 0;

(Does List::MoreUtils::any() short-circuit evaluate its list? I don't know, but I would presume it does.)

Replies are listed 'Best First'.
Re^2: Short-circuiting a map list.
by BrowserUk (Patriarch) on Oct 08, 2011 at 02:07 UTC

    How do two functions which both return true or false, return the input list until a condition is met?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-19 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found