aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/SEG.ht
blob: 03b5cbf76d570ffbbdfdfa242eab71096191820e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
% 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.69}
%
% =====================================================================
\begin{page}{SegmentXmpPage}{9.69 Segment}
% =====================================================================
\beginscroll

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

\labelSpace{2pc}
\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{lo}{Segment}
and the second is called \spadfunFrom{hi}{Segment}.
}{
\spadpaste{lo s \free{s}}
}
\xtc{
These names are used even though the end points might belong to an
unordered set.
}{
\spadpaste{hi 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}
%