On Thu, Nov 13, 2008 at 09:40:19AM -0800, Larry Wall wrote:
> On Thu, Nov 13, 2008 at 05:02:56PM +0100, TSa wrote:
> > Patrick R. Michaud wrote:
> >> I expect that $a will become one(True, False, True).  $a doesn't
> >> collapse to a non-Junction False until it is used in a boolean context.
> >
> > My proposal is a different unification behavior in one() junctions.
> >
> >>         my $a = one(1,2,3) % 2 == 1;
> >>    -->  my $a = one(1%2, 2%2, 3%2) == 1;
> >      -->  my $a = one(1,0,1) == 1;
> >      -->  my $a = one(0) == 1;
> >      -->  my $a = one(0 == 1)
> >      -->  my $a = one(False);

I think your proposal (C<one> drops duplicates) might have 
trouble with:

      my $a = (one(15, 25, 22, 21) % 10) % 2;

Dropping duplicates, we get:

  --> my $a = one(15%10, 25%10, 22%10, 21%10) % 2;
  --> my $a = one(5, 5, 2, 1) % 2;
  --> my $a = one(2, 1) % 2;                 # omit duplicate 5
  --> my $a = one(2%2, 2%1);
  --> my $a = one(0, 1);

Preserving duplicates, we get:

      my $a = (one(15, 25, 22, 21) % 10) % 2;
  --> my $a = one(15%10, 25%10, 22%10, 21%10) % 2;
  --> my $a = one(5, 5, 2, 1) % 2;
  --> my $a = one(5%2, 5%2, 2%2, 1%2);
  --> my $a = one(1, 1, 0, 1);

Note that ?$a would end up being True if we drop duplicates (top)
but False if we preserve them (bottom).

> It seems simpler to say that one() produces bags rather than sets.

I agree, so Rakudo will go with that for now.

Thanks!

Pm

Reply via email to