Skip Menu |

This queue is for tickets about the Algorithm-Combinatorics CPAN distribution.

Report information
The Basics
Id: 63308
Status: open
Priority: 0/
Queue: Algorithm-Combinatorics

People
Owner: Nobody in particular
Requestors: DONANGEL [...] cpan.org
Cc: DONANGEL [...] cpan.org
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.25
Fixed in: (no value)



CC: DONANGEL [...] cpan.org
Subject: error in subroutine subsets
Hi! Error: superfluous, empty iteration in subroutine subsets() Example: ########### test.pl ########### #!/usr/bin/perl -w use strict; use Algorithm::Combinatorics qw( subsets ); my @a = ('A','B','C'); my $i; my $iter = subsets(\@a); while(my $base = $iter->next){ print ++$i, "\t", join ' ',@{ $base },"\n"; } ########### OUTPUT ########### 1 A B C 2 B C 3 A C 4 C 5 A B 6 B 7 A 8 <Empty> Why 8 <Empty>?
On Wed Nov 24 11:16:23 2010, DONANGEL wrote: Show quoted text
> Hi! > > Error: superfluous, empty iteration in subroutine subsets() > > Example: > ########### test.pl ########### > #!/usr/bin/perl -w > use strict; > use Algorithm::Combinatorics qw( subsets ); > > my @a = ('A','B','C'); > my $i; > my $iter = subsets(\@a); > while(my $base = $iter->next){ > print ++$i, "\t", join ' ',@{ $base },"\n"; > } > > ########### OUTPUT ########### > 1 A B C > 2 B C > 3 A C > 4 C > 5 A B > 6 B > 7 A > 8 <Empty> > > Why 8 <Empty>?
It's the empty set. The empty set is a subset of any set, you'll get always that one.
Срд Ноя 24 11:28:25 2010, FXN писал: Show quoted text
> It's the empty set. The empty set is a subset of any set, you'll get > always that one.
Many thanks for the module. Now it is clear. And it is possible to add in subroutine subsets an option disconnecting empty set? It would be remarkable.
Has hurried. Such variant of subsets is possible? subsets(\@data[, $max, $min]) optional parameters: $max ($k) --- the iteration runs over subsets of data of size $max ($k) $min --- the bottom limit. For example: subsets( [A, B, C, D], 4, 2]) Output: A B C D A B C A B D A C D B C D A B A C A D B C B D C D