Skip to content

Commit

Permalink
Move postcircumfix:<[ ]> into Any.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Jul 5, 2010
1 parent 22d0c39 commit 08e5b03
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
21 changes: 21 additions & 0 deletions src/core/Any-list.pm
Expand Up @@ -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) }
Expand Down
19 changes: 0 additions & 19 deletions 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 {
Expand Down

0 comments on commit 08e5b03

Please sign in to comment.