Intervals

Interval of real numbers in mathematics can be can be represented using the keyword to. For example, the closed interval can be created by
>> s = 0 to 1;   // interval [0, 1]
Note that since any single value is the same as a list whose only entry is that value. Therefore, 0 to 1 is equivalent to (0 to 1), and we can write
>> s = (0 to 1);  // interval [0, 1]
Open and half open intervals are created using suffix + and -. For example
>> s1 = (0 to 1);   // interval [0, 1]
>> s2 = (0+ to 1-);   // open interval (0, 1)
>> s3 = (0+ to 1);   // half open interval (0, 1]
>> s4 = (0 to 1-);   // half open interval [0, 1)
>> s5 = (0 to inf);   // interval [0, inf)
>> s6 = (-inf to 1);   // interval (-inf, 1]
>> s7 = (-inf to inf);   // interval (-inf, inf) equivalent to _R



oz 2009-12-22