Permalink
Browse files

Introducing R:Q.MIX-CLONE-ALL-POSITIVE

Make sure that all values of keys in a R:I:IterationSet with Mixy
semantics have a positive value.
  • Loading branch information...
lizmat committed Jul 13, 2017
1 parent f6e25b5 commit 3f6bffdbceca081f147f9de50d613f4f49f70590
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/core/Rakudo/QuantHash.pm
@@ -1370,6 +1370,28 @@ my class Rakudo::QuantHash {
)
)
}
method MIX-CLONE-ALL-POSITIVE(\elems) {
nqp::stmts(
(my $iter := nqp::iterator(my $clone := nqp::clone(elems))),
nqp::while(
$iter,
nqp::stmts(
nqp::shift($iter),
nqp::bindkey(
$clone,
nqp::iterkey_s($iter),
nqp::p6bindattrinvres(
nqp::clone(nqp::iterval($iter)),
Pair,
'$!value',
abs(nqp::getattr(nqp::iterval($iter),Pair,'$!value'))
)
)
)
),
$clone
)
}
method MIX-ALL-POSITIVE(\elems) {
nqp::stmts(
(my $iter := nqp::iterator(elems)),

0 comments on commit 3f6bffd

Please sign in to comment.