# 9.69 SegmentΒΆ

The Segment domain provides a generalized interval type.

Segments are created using the .. construct by indicating the (included) end points.

```
s := 3..10
```

3..10 |

_{Type: Segment PositiveInteger}

The first end point is called the loloSegment and the second is called hihiSegment.

```
lo s
```

3 |

_{Type: PositiveInteger}

These names are used even though the end points might belong to an unordered set.

```
hi s
```

10 |

_{Type: PositiveInteger}

In addition to the end points, each segment has an integer increment. An increment can be specified using the by construct.

```
t := 10..3 by -2
```

10..3by -2 |

_{Type: Segment PositiveInteger}

This part can be obtained using the incrincrSegment function.

```
incr s
```

1 |

_{Type: PositiveInteger}

Unless otherwise specified, the increment is 1.

```
incr t
```

-2 |

_{Type: Integer}

A single value can be converted to a segment with equal end points. This happens if segments and single values are mixed in a list.

```
l := [1..3, 5, 9, 15..11 by -1]
```

[1..3,5..5,9..9,15..11by-1] |

_{Type: List Segment PositiveInteger}

If the underlying type is an ordered ring, it is possible to perform additional operations. The expandexpandSegment operation creates a list of points in a segment.

```
expand s
```

[3,4,5,6,7,8,9,10] |

_{Type: List Integer}

If k > 0, then expand(l..h by k) creates the list [l, l+k, ..., lN] where lN <= h < lN+k. If k < 0, then lN >= h > lN+k.

```
expand t
```

[10,8,6,4] |

_{Type: List Integer}

It is also possible to expand a list of segments. This is equivalent to appending lists obtained by expanding each segment individually.

```
expand l
```

[1,2,3,5,9,15,14,13,12,11] |

_{Type: List Integer}

For more information on related topics, see SegmentBindingXmpPage and UniversalSegmentXmpPage .