diff --git a/src/core/Any-list.pm b/src/core/Any-list.pm index 989029083d2..2fb3304a1f5 100644 --- a/src/core/Any-list.pm +++ b/src/core/Any-list.pm @@ -277,6 +277,27 @@ augment class Any { multi method pairs() { self.kv.map(-> $key, $value { $key => $value; }); } + + our multi method postcircumfix:<[ ]>() { self.list } + + our multi method postcircumfix:<[ ]>(&block) { self[&block(self.elems)]; } + + our multi method postcircumfix:<[ ]>(@pos) { + my $result = pir::new__ps('ResizablePMCArray'); + for @pos { + pir::push($result, self[$_]) + } + Q:PIR { + $P0 = find_lex '$result' + %r = '&infix:<,>'($P0 :flat) + } + } + + our multi method postcircumfix:<[ ]>($pos) { + fail "Cannot use negative index $pos on {self.WHO}" if $pos < 0; + self.at_pos($pos) + } + } proto sub classify($matcher, *@values) { @values.classify($matcher) } diff --git a/src/core/Positional.pm b/src/core/Positional.pm index c4bab5be35e..fde5c1f161a 100644 --- a/src/core/Positional.pm +++ b/src/core/Positional.pm @@ -1,23 +1,4 @@ role Positional[::T = Mu] { - our multi method postcircumfix:<[ ]>() { self.list } - - our multi method postcircumfix:<[ ]>(&block) { self[&block(self.elems)]; } - - our multi method postcircumfix:<[ ]>(@pos) { - my $result = pir::new__ps('ResizablePMCArray'); - for @pos { - pir::push($result, self[$_]) - } - Q:PIR { - $P0 = find_lex '$result' - %r = '&infix:<,>'($P0 :flat) - } - } - - our multi method postcircumfix:<[ ]>($pos) { - fail "Cannot use negative index $pos on {self.WHO}" if $pos < 0; - self.at_pos($pos) - } method at_pos($pos) { Q:PIR {