Interval
An Interval represents a continuous range of numbers between two bounds. Both endpoints are contained in the interval. Moreover, the interval can be unbounded; but this iteration won't allow to construct open intervals.
- [x] Syntax
[expr .. expr]to construct a closed interval #13 - [x] Typing: the interval is not templated #15
- [x] Implements the operator
inasvalue in the intervalwhich verifies that the value is in the interval (1*) #14 - [x] Implements the getters
intervalUpperBound,intervalLowerBound, andintervalIsEmpty(2*) #20 - [x] Implements
bool(interval)asnot intervalIsEmpty(interval)#20 - [x] Implements the method
intervalToArray(interval, step), which constructs an array containing all values in the interval separated bystep. This argument can be negative, constructing the values from the end. This returns null and displays an error for an opened interval. #17 - [x] Implements
intervalIsBounded#23 - [x] Implements the constructor
Interval(real from, real to)(2*) #23 - [x] Syntax
[.. expr],[expr..], and[..]for unbounded interval. Infinities can also be used. #23 - [x] Implements
intervalMidpoint. For empty or unbounded intervals, it returns null. #26 - [x] Implements the method
intervalIntersectionwhich returns the interval to which all values lie in both intervals. #26 - [x] Implements the method
intervalCombinewhich returns the minimum interval containing both intervals. (3*) #26 - [x] Implements
intervalIsLeftBoundedandintervalIsRightBounded#26 - [x] Implements slices
interval[start:end:stride]which is equivalent tointervalToArray(interval, stride)[start:end]#26 - [ ] ~~Implements the arithmetic operators (
+,-,*,/) for interval:[1..2] + 5 === [6..7](the operation is applied on both endpoints).~~
1*: The in operator can be extended to arrays and maps. For maps, the value is checked against keys.
2*: An open interval returns +/-infinity as lower/upper bounds. Infinities can also be used in the constructor.
3*: Union is a term more often used, but it's not defined for disconnected intervals. intervalCombine will be a generalization to all pairs of intervals. If a user wants the strict union, they can verify first that the intersection is non-empty.
Arithmetic operators are a bit complicated to implements + it's not an important feature => removed
- [ ] Interval operator[]
var i = [100..200] i[50] // 150 - [ ]
[1.0..2.0]issue with lexer - [ ] Add an error on
var i = [0.."salut"] - [x] Opened intervals
]x..y[ - [x] Empty interval
[..] - [ ] Empty collection
∅?