Help for this page

Select Code to Download


  1. or download this
        [
            # First loop: all item indices
    ...
                    : []
            } ) x $#items,
        ],
    
  2. or download this
    for $_ (  0..$#items  ) {
        # ...
    ...
            }
        }
    }
    
  3. or download this
            OnlyWhen => sub {
                # Compute sum of selected items as
    ...
                # Return subsets that match desired sum:
                return $sum[@_] == $target;
            },
    
  4. or download this
    @_= ();
    for $_ (  0..$#items  ) {
    ...
        }
        pop @_;
    }
    
  5. or download this
    $sum[@_] < $target ? [ ($_+1)..$#items ] : []
    
  6. or download this
        next   if  $target <= $sum[@_];
    
  7. or download this
    @_= ();
    for $_ (  0..$#items  ) {
    ...
    } continue {
        pop @_;
    }
    
  8. or download this
    while(  my @list= @items[ $iter->() ]  ) {
        warn "$target = sum( @list )\n";
    }