-
Notifications
You must be signed in to change notification settings - Fork 3
Ranges
vorov2 edited this page Feb 26, 2020
·
1 revision
This article discusses ranges in Ela.
Ranges in Ela are arithmetic sequences that can be used to generate lists. You only have to specify a first element, a last element, and (optionally) a second element that will be used to calculate stepping.
Ranges are created using special literal syntax:
"[" first[,step]..[last] "]"
Here is an example of a simple range:
[1..10]
You can specify an optional step in a range:
[1,3..10]
If the first element of a range is lesser than the last element of a range, a step is mandatory:
[10,9..1]
It is possible to construct non-strict ranges (such as infinite lists). In this case the last element in range should be omitted:
[1..]
[1,8..]
[100,98..]