Skip to content
Permalink
Browse files

Make sure immutable structures also work with Associatives

- such as: dd (a => 42, b => 666).Map >>+>> 2  # Map.new((:a(44),:b(668)))
- alas, we need customized Associative handling for QuantHashes
  - .STORE expects Pairs for QuantHashes
  • Loading branch information...
lizmat committed Nov 11, 2018
1 parent 63ae9dc commit fa5215b61b8e0e35a2a64d6231b3af118dc52903
Showing with 12 additions and 8 deletions.
  1. +12 −8 src/core/Hyper.pm6
@@ -41,12 +41,13 @@ class Hyper {
# %x >>op<< y
multi method infix(Associative:D \left, \right --> Associative:D) {
my @keys is List = left.keys;
my \result := left.WHAT.new.STORE(
my \result := nqp::create(left.WHAT).STORE(
Seq.new(
Rakudo::Iterator.RoundrobinIterablesFlat(
(@keys, self.infix(left{@keys}, right))
)
)
),
:INITIALIZE
);
nqp::iscont(left) ?? result.item !! result;
}
@@ -60,12 +61,13 @@ class Hyper {
# x >>op<< %y
multi method infix(\left, Associative:D \right --> Associative:D) {
my @keys is List = right.keys;
my \result := right.WHAT.new.STORE(
my \result := nqp::create(right.WHAT).STORE(
Seq.new(
Rakudo::Iterator.RoundrobinIterablesFlat(
(@keys, self.infix(left, right{@keys}))
)
)
),
:INITIALIZE
);
nqp::iscont(right) ?? result.item !! result;
}
@@ -288,12 +290,13 @@ class Hyper {
nqp::p6bindattrinvres(nqp::create(Map),Map,'$!storage',$keys).keys;

# run with the left/right values
my \result := left.WHAT.new.STORE(
my \result := nqp::create(left.WHAT).STORE(
Seq.new(
Rakudo::Iterator.RoundrobinIterablesFlat(
(@keys, quietly self.infix(left{@keys}, right{@keys}))
)
)
),
:INITIALIZE
);
nqp::iscont(left) ?? result.item !! result;
}
@@ -316,12 +319,13 @@ class Hyper {
nqp::p6bindattrinvres(nqp::create(Map),Map,'$!storage',$keys).values;

# run with the left/right values
my \result := left.WHAT.new.STORE(
my \result := nqp::create(left.WHAT).STORE(
Seq.new(
Rakudo::Iterator.RoundrobinIterablesFlat(
(@keys, quietly self.infix(left{@keys}, right{$keys}))
)
)
),
:INITIALIZE
);
nqp::iscont(left) ?? result.item !! result;
}

0 comments on commit fa5215b

Please sign in to comment.
You can’t perform that action at this time.