Commit b4fda4ae authored by Daniel Agar's avatar Daniel Agar

fixes #169 - allow a negative step in xrange

parent a239c80b
......@@ -43,8 +43,12 @@ public:
static bool xrangeIteratorHasnextUnboxed(Box* s) __attribute__((visibility("default"))) {
assert(s->cls == xrange_iterator_cls);
BoxedXrangeIterator* self = static_cast<BoxedXrangeIterator*>(s);
assert(self->xrange->step > 0);
return self->cur < self->xrange->stop;
if (self->xrange->step > 0) {
return self->cur < self->xrange->stop;
} else {
return self->cur > self->xrange->stop;
}
}
static Box* xrangeIteratorHasnext(Box* s) __attribute__((visibility("default"))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment