Subject: | Documentation assumes overly trivial 'any' implementation |
In the documentation, the argument for denying any assumes an overly trivial implementation of any/all/none
While I totally agree that any(@) would be pointless, what would be of GREAT benefit would be an any(&@) implementation. Technically, it's almost identical to first(&@), but returns true/false rather than the value.
As for just doing C< sub any(&@) { !! first(@_) } >, well I've tried it, and it fails for things like
any { ! defined $_ } @params
The code I normally use to implement it is
# The 'any' logical list test
sub any(&@) {
my $code = shift;
foreach ( @_ ) {
return 1 if &{$code}();
}
'';
}
I notice that's quite similar to your first implementation.
I imagine the C would be pretty copy/pastable as well ( Not a C person ).
In summary, while I agree on the uselessness of any(@) can I convince you to add any(@&) so I can remove it from the 53 locations I've had to implement it myself throughout various modules and projects?