Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement List.(index|rindex)
  • Loading branch information
lizmat committed Apr 23, 2014
1 parent 48937da commit ad4b22b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/List.pm
Expand Up @@ -175,6 +175,22 @@ my class List does Positional { # declared in BOOTSTRAP
Any
)
}
method index(Mu $test) is rw {
my $index = -1;
self.map: {
$index++;
return $index if $_ ~~ $test;
};
Nil;
}
method rindex(Mu $test) is rw {
my $index = self.elems;
self.reverse.map: {
$index--;
return $index if $_ ~~ $test;
};
Nil;
}

method pick($n is copy = 1) {
fail "Cannot .pick from infinite list" if self.infinite; #MMD?
Expand Down

0 comments on commit ad4b22b

Please sign in to comment.