RangeIterator helper functions allow to use RangeItartor in easier usage in loop statements.
- Example
foreach my
int $i in(
xrange(5))
# resulting in:
# i=0
# i=1
# i=2
# i=3
# i=4
# i=5
RangeIterator Qore::xrange |
( |
int |
start, |
|
|
int |
stop, |
|
|
int |
step = 1 |
|
) |
| |
Returns a RangeIterator containing an arithmetic progression of integers.
- Code Flags:
- RET_VALUE_ONLY
- Example:
xrange(2, -2); # 2, 1, 0, -1, -2
xrange(-10, 10, 5); # -10, -5, 0, 5, 10
xrange(10, -10, 5); # 10, 5, 0, -5, -10
- Parameters
-
start | the initial value |
stop | the final value |
step | the step; the default is 1; must be greater than 0; the function throws a RANGE-ERROR exception when this argument is < 1 |
- Return values
-
Returns | a RangeIterator containing an arithmetic progression of integers. |
- Exceptions
-
RANGEITERATOR-ERROR | this exception is thrown if step < 1 |
- See also
- range
- Note
- the main difference between range() and xrange() is that range returns a real list and xrange() returns a RangeIterator
- Since
- Qore 0.8.6
RangeIterator Qore::xrange |
( |
int |
stop | ) |
|