Range operator

Figure 28. RangeExpr


With the binary operator "to", you can generate larger sequences with just two integer operands.

Example 42. Range operator

1 to 10

Result (run with Zorba): 1 2 3 4 5 6 7 8 9 10

If one operand evaluates to the empty sequence, then the range operator returns the empty sequence.

Example 43. Range operator with the empty sequence

() to 10, 1 to ()

Result (run with Zorba): 

Otherwise, if an operand evaluates to something else than a single integer or an empty sequence, an error is raised.

Example 44. Range operator with a type inconsistency

(1, 2) to 10

Result (run with Zorba): An error was raised: sequence of more than one item can not be promoted to parameter type xs:integer? of function to()