- 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 );
}
- 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 == @_;
- or download this
# otherwise..
my $include_iter = iter_choose_n(@rest, $n-1);
...
return $exclude_iter->();
}
}
- or download this
# otherwise..
my $include_iter = iter_choose_n(@rest, $n-1);
...
}
}
}
- or download this
# otherwise..
my $include_iter = iter_choose_n(@rest, $n-1);
...
}
}
}