hash_slice.pm6 (rakudo-2020.09) | : | hash_slice.pm6 (rakudo-2020.10) | ||
---|---|---|---|---|
skipping to change at line 174 | skipping to change at line 174 | |||
nqp::elems(nqp::getattr(%other,Map,'$!storage')) | nqp::elems(nqp::getattr(%other,Map,'$!storage')) | |||
?? SLICE_MORE_HASH( SELF, SELF.keys.list, 'v', $v, %other ) | ?? SLICE_MORE_HASH( SELF, SELF.keys.list, 'v', $v, %other ) | |||
!! SELF{SELF.keys.list}; | !! SELF{SELF.keys.list}; | |||
} | } | |||
multi sub postcircumfix:<{ }>(Mu \SELF, *%other ) is raw { | multi sub postcircumfix:<{ }>(Mu \SELF, *%other ) is raw { | |||
nqp::elems(nqp::getattr(%other,Map,'$!storage')) | nqp::elems(nqp::getattr(%other,Map,'$!storage')) | |||
?? SELF.ZEN-KEY(|%other) | ?? SELF.ZEN-KEY(|%other) | |||
!! nqp::decont(SELF) | !! nqp::decont(SELF) | |||
} | } | |||
proto sub postcircumfix:<{; }>($, $, *%) is nodal {*} | ||||
multi sub postcircumfix:<{; }>(\SELF, @indices) { | ||||
sub MD-HASH-SLICE-ONE-POSITION(\SELF, \indices, \idx, int $dim, \target) { | ||||
my int $next-dim = $dim + 1; | ||||
if $next-dim < indices.elems { | ||||
if nqp::istype(idx, Iterable) && !nqp::iscont(idx) { | ||||
MD-HASH-SLICE-ONE-POSITION(SELF, indices, $_, $dim, target) | ||||
for idx; | ||||
} | ||||
elsif nqp::istype(idx, Str) { | ||||
MD-HASH-SLICE-ONE-POSITION(SELF.AT-KEY(idx), | ||||
indices, indices.AT-POS($next-dim), $next-dim, target) | ||||
} | ||||
elsif nqp::istype(idx, Whatever) { | ||||
MD-HASH-SLICE-ONE-POSITION(SELF.AT-KEY($_), | ||||
indices, indices.AT-POS($next-dim), $next-dim, target) | ||||
for SELF.keys; | ||||
} | ||||
else { | ||||
MD-HASH-SLICE-ONE-POSITION(SELF.AT-KEY(idx), | ||||
indices, indices.AT-POS($next-dim), $next-dim, target) | ||||
} | ||||
} | ||||
else { | ||||
if nqp::istype(idx, Iterable) && !nqp::iscont(idx) { | ||||
MD-HASH-SLICE-ONE-POSITION(SELF, indices, $_, $dim, target) | ||||
for idx; | ||||
} | ||||
elsif nqp::istype(idx, Str) { | ||||
nqp::push(target, SELF.AT-KEY(idx)) | ||||
} | ||||
elsif nqp::istype(idx, Whatever) { | ||||
for SELF.keys { | ||||
nqp::push(target, SELF.AT-KEY($_)) | ||||
} | ||||
} | ||||
else { | ||||
nqp::push(target, SELF.AT-KEY(idx)) | ||||
} | ||||
} | ||||
} | ||||
my \target = nqp::create(IterationBuffer); | ||||
MD-HASH-SLICE-ONE-POSITION(SELF, @indices, @indices.AT-POS(0), 0, target); | ||||
target.List | ||||
} | ||||
multi sub postcircumfix:<{; }>(\SELF, @indices, :$exists!) { | ||||
sub recurse-at-key(\SELF, \indices) { | ||||
my \idx := indices[0]; | ||||
my \exists := SELF.EXISTS-KEY(idx); | ||||
nqp::if( | ||||
nqp::istype(idx, Iterable), | ||||
idx.map({ |recurse-at-key(SELF, ($_, |indices.skip.cache)) }).List, | ||||
nqp::if( | ||||
nqp::iseq_I(indices.elems, 1), | ||||
exists, | ||||
nqp::if( | ||||
exists, | ||||
recurse-at-key(SELF{idx}, indices.skip.cache), | ||||
nqp::stmts( | ||||
(my \times := indices.map({ .elems }).reduce(&[*])), | ||||
nqp::if( | ||||
nqp::iseq_I(times, 1), | ||||
False, | ||||
(False xx times).List | ||||
) | ||||
).head | ||||
) | ||||
) | ||||
); | ||||
} | ||||
recurse-at-key(SELF, @indices) | ||||
} | ||||
# vim: expandtab shiftwidth=4 | # vim: expandtab shiftwidth=4 | |||
End of changes. 1 change blocks. | ||||
77 lines changed or deleted | 0 lines changed or added |