Skip to content

Commit

Permalink
Simplify infix:<(+)>(**@p) candidate
Browse files Browse the repository at this point in the history
With all of the necessary candidates and testing for them in place,
we can now do that
  • Loading branch information
lizmat committed Jul 17, 2017
1 parent 6c76ed0 commit d82db18
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/core/set_addition.pm
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,10 @@ multi sub infix:<(+)>(Any $a, Any $b) {
)
}

multi sub infix:<(+)>(**@p) is pure {
if Rakudo::Internals.ANY_DEFINED_TYPE(@p,Mixy) {
my $mixhash = nqp::istype(@p[0], MixHash)
?? MixHash.new-from-pairs(@p.shift.pairs)
!! @p.shift.MixHash;
for @p.map(*.Mix(:view)) -> $mix {
$mixhash{$_} += $mix{$_} for $mix.keys;
}
$mixhash.Mix(:view);
}
else { # go Baggy by default
my $baghash = nqp::istype(@p[0], BagHash)
?? BagHash.new-from-pairs(@p.shift.pairs)
!! @p.shift.BagHash;
for @p.map(*.Bag(:view)) -> $bag {
$baghash{$_} += $bag{$_} for $bag.keys;
}
$baghash.Bag(:view);
}
multi sub infix:<(+)>(**@p) {
my $result = @p.shift;
$result = $result (+) @p.shift while @p;
$result
}

# U+228E MULTISET UNION
Expand Down

0 comments on commit d82db18

Please sign in to comment.