Help for this page

Select Code to Download


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