Skip to content
Permalink
Browse files

Fix Range.reverse.count-only

  • Loading branch information...
lizmat committed Sep 11, 2018
1 parent 0a2d832 commit d970c2b336b43dc25c9922fca6643d2ffb095e7b
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/core/Range.pm6
@@ -189,7 +189,9 @@ my class Range is Cool does Iterable does Positional {
$target.push(nqp::p6box_i($i)) while ($i = $i - 1) >= $n;
$!i = $i;
}
method count-only() { nqp::p6box_i($!i - $!n) }
method count-only(--> Int:D) {
nqp::p6box_i($!i - $!n + nqp::isgt_i($!n,$!i))
}
method sink-all(--> IterationEnd) { $!i = $!n }
}
my class InfReverse does Iterator {
@@ -228,7 +230,9 @@ my class Range is Cool does Iterable does Positional {
$target.push(nqp::chr($i)) while ($i = $i - 1) >= $n;
$!i = $i;
}
method count-only() { nqp::p6box_i($!i - $!n) }
method count-only(--> Int:D) {
nqp::p6box_i($!i - $!n + nqp::isgt_i($!n,$!i))
}
method sink-all(--> IterationEnd) { $!i = $!n }
}
my class Pred does Iterator {

0 comments on commit d970c2b

Please sign in to comment.
You can’t perform that action at this time.