And Smylers did write:

David Landgren writes:


... my main question concerns the name. Is it good? Did you understand
what the module would do when your saw the subject of this message in
your inbox?


No.  And I still don't understand what "WithoutReplacement" means in
this context -- after reading those terms in the title, I was expecting
them to crop up again somewhere in the synopsis or the description.

Ah yes, well, like any unfinished project the documentation needs work.

The implication is that ordinarily when selecting something it is
replaced -- but I've no idea what that means.

That would mean that from (a, b, c), you could draw, for example, (a, a, c) or (a, b, b).


Is there a better name(?:space)? for this?


It looks to me that this module when given a set returns its power set:

  http://en.wikipedia.org/wiki/Power_set

so perhaps Data::PowerSet is appropriate.

Aha! Quite. Thanks for the term.

Except that it isn't clear what your module does if the input list
contains duplicate items.  Sets can't contain duplicates; if your module
just sees a list with 5 items in it and permutes those items by their
indices then it wouldn't even notice the dupes, so obviously it isn't
(solely) working with sets.

Indeed. If the user wants to have duplicate items, who am I to throw up my mathematical-purity arms in horror? And it turns out that there's quite a good reason why one would want to:

I have 4 coins in my pocket: 2, 2, 5, 20. What amounts can I make with that?

use Data::PowerSet;

my $d = Data::PowerSet->new( @ARGV );

while( my $r = $d->next ) {
    print sum(@$r), "\t(@$r)\n";
}

sub sum {
    my $s = 0;
    $s += $_ for @_;
    return $s;
}
__END__

gives:

19      (2 2 5 10)
17      (2 5 10)
17      (2 5 10)
15      (5 10)
14      (2 2 10)
12      (2 10)
12      (2 10)
10      (10)
9       (2 2 5)
7       (2 5)
7       (2 5)
5       (5)
4       (2 2)
2       (2)
2       (2)
0       ()

A neat thing that falls out of this is that so long as your amounts are sorted, you only need to keep track of the previous set to track duplicates.

But the module name is supposed to be "best fit" rather than "perfect",
so even if your module also provides analogous behaviour on things that
aren't sets, I don't think that would bar it from using PowerSet in its
name.

Phew.


(I rule out Algorithm::*, since the you're not actually supposed to
care how it does its business, only that it does it).


That's a good point, and I completely agree with you on it.

So, does anyone have an objection to Data::PowerSet?

Thanks,
David

Reply via email to