| 217 | | === Range literals: `lo .. hi` #range-literals |
| 218 | | |
| 219 | | An expression of the form `lo .. hi` where `lo` and `hi` are integer expressions, represents the range consisting of the integers `lo`, `lo` + 1, ..., `hi` (in that order). |
| 220 | | An expression of the form `lo .. hi # step`, where `lo`, `hi`, and `step` are integer expressions is interpreted as follows. |
| 221 | | If `step` is positive, it represents the range consisting of `lo`, `lo` + `step`, `lo` + 2 ∗ `step`, …, up to and possibly including `hi`. |
| 222 | | To be precise, the infinite sequence is intersected with the set of integers less than or equal to `hi`. |
| 223 | | If `step` is negative, the expression represents the range consisting of `hi`, `hi` + `step`, `hi` + 2 ∗ `step`, . . ., down to and possibly including `lo`. |
| 224 | | Precisely, the infinite sequence is intersected with the set of integers greater than or equal to `lo`. |
| | 217 | === Range literals: ''a''`..`''b'' and ''a''`..`''b''`#`''c'' #range-literals |
| | 218 | |
| | 219 | A range literal has form |
| | 220 | ''expr'' `..` ''expr'' ( `#` ''expr'' )? |
| | 221 | The two or three sub-expressions (the third is optional) have integer type and the type of the entire expression is `$range`. |
| | 222 | |
| | 223 | The range literal ''a''`..`''b'' represents the range consisting of the integers ''a'', ''a''+1, ..., ''b'' (in that order). |
| | 224 | |
| | 225 | The range literal ''a''`..`''b''`#`''c'' is interpreted as follows. |
| | 226 | If ''c'' is positive, it represents the range consisting of ''a'', ''a''+''c'', ''a''+2''c'', ..., up to and possibly including ''b''. |
| | 227 | To be precise, the infinite sequence is intersected with the set of integers less than or equal to ''b''. |
| | 228 | If ''c'' is negative, the expression represents the range consisting of ''b'', ''b''+''c'', ''b''+2''c'', ..., down to and possibly including ''a''. |
| | 229 | Precisely, the infinite sequence is intersected with the set of integers greater than or equal to ''a''. |