Help for this page

Select Code to Download


  1. or download this
    # Given a list of M items and a number N,
    # generate all size-N subsets of M
    ...
        return ( (map {[$first, @$_]} @include_combos)
             , @exclude_combos );
    }
    
  2. or download this
    sub iter_choose_n {
        my $n = pop;
    ...
        return sub {$once++ ? () : []} if $n == 0  or $n > @_;
        my ($first, @rest) = @_;
        return sub {$once++ ? () : [$first, @rest]} if $n == @_;
    
  3. or download this
        # otherwise..
        my $include_iter = iter_choose_n(@rest, $n-1);
    ...
                return $exclude_iter->();
            }
        }
    
  4. or download this
        # otherwise..
        my $include_iter = iter_choose_n(@rest, $n-1);
    ...
            }
        }
    }
    
  5. or download this
        # otherwise..
        my $include_iter = iter_choose_n(@rest, $n-1);
    ...
            }
        }
    }