The most confusing thing about this operator, in all its guises, is that it is not a syntactic construction, and so the resulting sequences do not splice themselves into enclosing lists, as in each of the following examples.
i1 : {10..<11} o1 = {1 : (10)} o1 : List |
i2 : {10..<8} o2 = {()} o2 : List |
i3 : {3..<5,8..<10} o3 = {(3, 4), (8, 9)} o3 : List |
Use splice to fix that.
i4 : splice {3..<5,8..<10} o4 = {3, 4, 8, 9} o4 : List |
If a type of list, instead of a sequence, is desired, use toList or the operator new.
i5 : 0..<5 o5 = (0, 1, 2, 3, 4) o5 : Sequence |
i6 : toList (0..<5) o6 = {0, 1, 2, 3, 4} o6 : List |
i7 : new Array from 0..<5 o7 = [0, 1, 2, 3, 4] o7 : Array |
i8 : new Sum from 0..<5 o8 = 0 + 1 + 2 + 3 + 4 o8 : Expression of class Sum |
The operator can be used with sequences or lists, whose elements are of various types, to produce rectangular intervals.
i9 : (0,0)..<(2,3) o9 = ((0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)) o9 : Sequence |
i10 : p_(0,a) ..< r_(2,c) o10 = (p , p , p , p , q , q , q , q ) 0,a 0,b 1,a 1,b 0,a 0,b 1,a 1,b o10 : Sequence |
Use .. instead to get a sequence that does not stop short of the endpoint.
This operator may be used as a binary operator in an expression like x..<y. The user may install binary methods for handling such expressions with code such as
X ..< Y := (x,y) -> ...
where X is the class of x and Y is the class of y.