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 |