Real from = (*from_)(t).get(Real());
Real to = (*to_ )(t).get(Real());
Real step = (*step_)(t).get(Real());
Real from = (*from_)(t).get(Real());
Real to = (*to_ )(t).get(Real());
Real step = (*step_)(t).get(Real());
if (step == 0) return false;
if (step == 0) return false;
- index += step;
- return index <= to;
+ if ((index += step) <= to) return true;
- {
- index -= step;
- return index >= to;
- }
+ if ((index -= step) >= to) return true;
+
+ // at the end of the loop, leave the index at the last value that was used
+ index = prev;
+ return false;