- or download this
$sum = eval join ' + ', @addends;
- or download this
$all_true = eval join ' && ', @flags;
- or download this
sub AND { ! grep !$_, @_ }
sub OR { !!grep $_, @_ }
- or download this
DB<1> p AND()
1
...
1
DB<7> p OR(2, 3, 0, 1)
1
- or download this
use List::Util 'first';
sub AND { ! first { !$_ } @_ }
sub OR { !!first { $_ } @_ }
- or download this
DB<1> p OR(0)
...
1
DB<4> p OR(undef, 2, 0, 'x')
1
- or download this
DB<1> p AND(0)
1
...
1
DB<4> p AND(undef, 2, 0, 'x')
1
- or download this
sub AND { $_ || return 0 for @_; 1 }
sub OR { $_ && return 1 for @_; 0 }
...
1
DB<8> p OR(undef, 2, 0, 'x')
1
- or download this
use List::Util 'reduce';
sub add { reduce { $a + $b } ( 0, @_ ) }
sub mult { reduce { $a * $b } ( 1, @_ ) }