9.84 UniversalSegment

The UniversalSegment domain generalizes Segment by allowing segments without a hi end point.

pints := 1..
\[\]
1..

Type: UniversalSegment PositiveInteger

nevens := (0..) by -2
\[\]
0..by -2

Type: UniversalSegment NonNegativeInteger

Values of type Segment are automatically converted to type UniversalSegment when appropriate.

useg: UniversalSegment(Integer) := 3..10
\[\]
3..10

Type: UniversalSegment Integer

The operation hasHihasHiUniversalSegment is used to test whether a segment has a hi end point.

hasHi pints
\[\]
false

Type: Boolean

hasHi nevens
\[\]
false

Type: Boolean

hasHi useg
\[\]
true

Type: Boolean

All operations available on type Segment apply to UniversalSegment, with the proviso that expansions produce streams rather than lists. This is to accommodate infinite expansions.

expand pints
\[\]
[1,2,3,4,5,6,7,8,9,10,…]

Type: Stream Integer

expand nevens
\[\]
[0,-2,-4,-6,-8,-10,-12,-14,-16,-18,…]

Type: Stream Integer

expand [1, 3, 10..15, 100..]
\[\]
[1,3,10,11,12,13,14,15,100,101,…]

Type: Stream Integer

For more information on related topics, see SegmentXmpPage , SegmentBindingXmpPage , ListXmpPage , and StreamXmpPage .