Skip to content

Commit

Permalink
Simplify [(^)] for 2+ with Baggy semantics
Browse files Browse the repository at this point in the history
Fixes the failing test in S03-operator/mix.t
  • Loading branch information
lizmat committed Jul 8, 2017
1 parent b391692 commit 05c255c
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/core/set_symmetric_difference.pm
Expand Up @@ -223,22 +223,9 @@ multi sub infix:<(^)>(Any $a, Any $b) { $a.Set (^) $b.Set }

multi sub infix:<(^)>(**@p) is pure {
if Rakudo::Internals.ANY_DEFINED_TYPE(@p,Baggy) {
my $head;
while (@p) {
my ($a, $b);
if $head.defined {
($a, $b) = $head, @p.shift;
} else {
($a, $b) = @p.shift, @p.shift;
}
if nqp::istype($a, Mixy) || nqp::istype($b, Mixy) {
($a, $b) = $a.MixHash, $b.MixHash;
} elsif nqp::istype($a, Baggy) || nqp::istype($b, Baggy) {
($a, $b) = $a.BagHash, $b.BagHash;
}
$head = ($a (-) $b) (+) ($b (-) $a);
}
return $head;
my $result = @p.shift;
$result = $result (^) @p.shift while @p;
$result
} else {
return ([(+)] @p>>.Bag).grep(*.value == 1).Set;
}
Expand Down

0 comments on commit 05c255c

Please sign in to comment.