RangeIterator helper functions allow to use RangeItartor in easier usage in loop statements.
- Example
- foreach int i in (xrange(5)) { -     printf("i=%d\n", i); - } 
◆ xrange() [1/2]
Returns a RangeIterator containing an arithmetic progression of integers. 
- Code Flags:
- RET_VALUE_ONLY
- Example:
- xrange(2, 5);  - xrange(2, -2);  - xrange(1, 10, 5);  - xrange(0, 10, 5);  - xrange(-10, 10, 5);  - xrange(10, -10, 5);  
- 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-ERRORexception when this argument is < 1 |  | val | an optional value to be returned instead of the default integer value |  
 
- 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
- Qore 0.8.11.1 this function takes the optional val argument
- Qore 0.9.5 does not include the upper limit in the range unless %broken-range is set 
 
 
 
◆ xrange() [2/2]
Returns a RangeIterator containing an arithmetic progression of integers with start = 0 and step = 1. 
This is an overloaded version of xrange(int, int, int) meaning xrange(0, stop, 1)
- Code Flags:
- CONSTANT
- Example:
- Parameters
- 
  
  
- Return values
- 
  
    | Returns | a RangeIterator containing an arithmetic progression of integers with start = 0 and 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
- Qore 0.9.5 does not include the upper limit in the range unless %broken-range is set