Range operator

JSONiq follows the W3C standard for range expressions. The following explanations, provided as an informal summary for convenience, are non-normative.

Figure 37. RangeExpr

RangeExpr

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

Example 67. 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 68. 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 69. 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()