Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement EXISTS-POS for Range
Fixes (1..10)[^5] giving only one result instead of 5.
Reason was that the POSITIONS implementation filters positions by EXISTS-POS
result. We inherited that from Any which always returns False.
  • Loading branch information
niner committed Aug 22, 2015
1 parent 40079e8 commit a52518d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/Range.pm
Expand Up @@ -59,6 +59,14 @@ my class Range is Cool does Iterable does Positional {
~ $!max;
}

multi method EXISTS-POS(Range:D: int \pos) {
self.List.EXISTS-POS(pos);
}

multi method EXISTS-POS(Range:D: Int \pos) {
self.List.EXISTS-POS(pos);
}

method elems {
return Inf if $!min === -Inf || $!max === Inf;
if nqp::istype($!min, Int) && nqp::istype($!max, Int) {
Expand Down

0 comments on commit a52518d

Please sign in to comment.