Subject: | Union fails for sets of different sizes |
It would be great if there were an option (or a function) to equalize
the size of a list of sets so that operations like Union could be run
more easily.
I wrote the following convenience function to equalize the size of a
list of sets:
sub Resize_sets {
my @sets = @_;
my ($min, $max) = sets_range(@sets);
$_->Resize($min, $max) for @sets;
return @sets;
}
sub sets_Range {
my @sets = @_;
return
(sort {$a <=> $b}
(map {$_->Min} @sets),
(map {$_->Max} @sets)
)[0,-1];
}
It seems strange that there isn't an option for Union to do this by
default, i.e. "$set1->Union($set2,$set3,{resize => 1})", or that there
isn't a function to do this, i.e. "$set2->Resize($set2,$set3)", etc.
Cheers,
Dan.