Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make grep/first/last-index return Pos
  • Loading branch information
lizmat committed Jul 24, 2015
1 parent 7c615ad commit f971dbd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 10 additions & 9 deletions src/core/Any.pm
@@ -1,5 +1,6 @@
my class MapIter { ... }
my class Pair { ... }
my class Pos { ... }
my class Range { ... }
my class X::Adverb::Slice { ... }
my class X::Bind { ... }
Expand Down Expand Up @@ -296,23 +297,23 @@ my class Any { # declared in BOOTSTRAP
self.map: {
$index = $index+1;
next unless .match($test);
nqp::box_i($index,Int);
nqp::box_i($index,Pos);
};
}
multi method grep-index(Callable:D $test) {
my int $index = -1;
self.map: {
$index = $index + 1;
next unless $test($_);
nqp::box_i($index,Int);
nqp::box_i($index,Pos);
};
}
multi method grep-index(Mu $test) {
my int $index = -1;
self.map: {
$index = $index + 1;
next unless $_ ~~ $test;
nqp::box_i($index,Int);
nqp::box_i($index,Pos);
};
}

Expand Down Expand Up @@ -341,23 +342,23 @@ my class Any { # declared in BOOTSTRAP
my int $index = -1;
self.map: {
$index = $index + 1;
return nqp::box_i($index,Int) if .match($test);
return nqp::box_i($index,Pos) if .match($test);
};
Nil;
}
multi method first-index(Callable:D $test) {
my int $index = -1;
self.map: {
$index = $index + 1;
return nqp::box_i($index,Int) if $test($_);
return nqp::box_i($index,Pos) if $test($_);
};
Nil;
}
multi method first-index(Mu $test) {
my int $index = -1;
self.map: {
$index = $index + 1;
return nqp::box_i($index,Int) if $_ ~~ $test;
return nqp::box_i($index,Pos) if $_ ~~ $test;
};
Nil;
}
Expand All @@ -373,7 +374,7 @@ my class Any { # declared in BOOTSTRAP
my int $index = $elems;
while $index {
$index = $index - 1;
return nqp::box_i($index,Int) if self.AT-POS($index).match($test);
return nqp::box_i($index,Pos) if self.AT-POS($index).match($test);
}
Nil;
}
Expand All @@ -384,7 +385,7 @@ my class Any { # declared in BOOTSTRAP
my int $index = $elems;
while $index {
$index = $index - 1;
return nqp::box_i($index,Int) if $test(self.AT-POS($index));
return nqp::box_i($index,Pos) if $test(self.AT-POS($index));
}
Nil;
}
Expand All @@ -395,7 +396,7 @@ my class Any { # declared in BOOTSTRAP
my int $index = $elems;
while $index {
$index = $index - 1;
return nqp::box_i($index,Int) if self.AT-POS($index) ~~ $test;
return nqp::box_i($index,Pos) if self.AT-POS($index) ~~ $test;
}
Nil;
}
Expand Down
2 changes: 0 additions & 2 deletions src/core/Cool.pm
Expand Up @@ -9,8 +9,6 @@ my class SprintfHandler {

my $sprintfHandlerInitialized = False;

my class Pos { ... }

my class Cool { # declared in BOOTSTRAP
# class Cool is Any {

Expand Down

0 comments on commit f971dbd

Please sign in to comment.