% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\SegmentXmpTitle}{Segment}
\newcommand{\SegmentXmpNumber}{9.73}
%
% =====================================================================
\begin{page}{SegmentXmpPage}{9.73 Segment}
% =====================================================================
\beginscroll

%
%
%
%
%



The \spadtype{Segment} domain provides a generalized interval type.

\xtc{
Segments are created using the \spadSyntax{..} construct
by indicating the (included) end points.
}{
\spadpaste{s := 3..10 \bound{s}}
}
\xtc{
The first end point is called the \spadfunFrom{low}{Segment}
and the second is called \spadfunFrom{high}{Segment}.
}{
\spadpaste{low(s) \free{s}}
}
\xtc{
These names are used even though the end points might belong to an
unordered set.
}{
\spadpaste{high(s) \free{s}}
}

\xtc{
In addition to the end points, each segment has an integer ``increment.''
An increment can be specified using the ``\spad{by}'' construct.
\spadkey{by}
}{
\spadpaste{t := 10..3 by -2 \bound{t}}
}
\xtc{
This part can be obtained using the \spadfunFrom{incr}{Segment} function.
}{
\spadpaste{incr(s) \free{s}}
}
\xtc{
Unless otherwise specified, the increment is \spad{1}.
}{
\spadpaste{incr(t) \free{t}}
}

\xtc{
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.
}{
\spadpaste{l := [1..3, 5, 9, 15..11 by -1] \bound{l}}
}

\xtc{
If the underlying type is an ordered ring, it is possible to perform
additional operations.
The \spadfunFrom{expand}{Segment} operation creates a list of
points in a segment.
}{
\spadpaste{expand(s) \free{s}}
}
\xtc{
If \spad{k > 0}, then \spad{expand(l..h by k)} creates the list
\spad{[l, l+k, ..., lN]} where \spad{lN <= h < lN+k}.
If \spad{k < 0}, then \spad{lN >= h > lN+k}.
}{
\spadpaste{expand(t) \free{t}}
}

\xtc{
It is also possible to expand a list of segments.  This is equivalent
to appending lists obtained by expanding each segment individually.
}{
\spadpaste{expand(l) \free{l}}
}

For more information on related topics, see
\downlink{`SegmentBinding'}{SegmentBindingXmpPage}\ignore{SegmentBinding} and
\downlink{`UniversalSegment'}{UniversalSegmentXmpPage}\ignore{UniversalSegment}.
%
\showBlurb{Segment}
\endscroll
\autobuttons
\end{page}
%
