$func Vector e.Source = s.Vector;
$func VectorToExp s.Vector = e.Exp;
$func VectorInit s.Vector s.Len e.Fill = ;
$func VectorFill s.Vector e.Fill = ;
$func VectorLength s.Vector = s.Len;
$func VectorRef s.Vector s.Index = e.Exp;
$func VectorSet s.Vector s.Index e.Exp = ;
$func VectorReplace s.Vector e.Source = ;
$func Subvector s.Vector s.Index s.Len = s.NewVector;
$func SubvectorFill s.Vector s.Index s.Len e.Fill = ;
These functions provide a way to create, modify, and access
vectors. The arguments of the functions must satisfy the
following restrictions. s.Vector must
be a reference to a vector, s.Index
and s.Len non-negative integers,
e.Fill an arbitrary ground
expression, e.Source a sequence of
references to vectors and terms of the form (Ge).
If one or more of the above restrictions are violated, the
result returned by the functions is $error(Fname "Invalid argument") , where
Fname is the function's name.
At any moment, a vector contains a finite sequence (which
may be empty) of ground expressions, which is said to be the
contents of the vector. A vector containing a sequence of
N+1 ground expressions
Ge0, Ge1, ..., GeN is said to have the length N+1. The contents of the vector will be written
as
(Ge0)(Ge1) ... (GeN)
Thus the vector components Ge0, Ge2, ..., GeN
are numbered starting from zero.
Vector creates a new vector
and returns a reference to the new vector. The contents of the
new vector is formed from e.Source in
the following way.
Suppose the parameter e.Source has
the form Gt1 Gt2 ... GtM,
where each ground term Gtj either is a reference to a vector,
or has the form (Ge). Then each term
Gtj is transformed as
follows.
If Gtj has the form
(Ge), Gtj is left unchanged.
If Gtj is a reference
to a vector, Gtj is
replaced with the contents of the vector (without changing the
state of the vector).
The value of the parameter e.Source thus transformed becomes the contents of
the new vector.
VectorToExp returns the ground
expression representing the contents of the vector referred to
by s.Vector.
VectorInit replaces the
contents of the vector referred to by s.Vector with a new contents of length
s.Len where all the components are
e.Fill.
VectorFill replaces each
component in the vector referred to by
s.Vector with e.Fill.
The length of the vector remains unchanged.
VectorLength returns the
length of the vector referred to by s.Vector.
VectorRef returns the ground
expression contained in the position s.Index in the vector referred to by s.Vector.
VectorSet replaces the ground
expression contained in the position s.Index in the vector referred to by s.Vector with e.Exp.
The length of the vector remains unchanged.
VectorReplace replaces the
contents of the vector referred to by s.Vector with the new contents formed from
e.Source in the same way as it is
done by the function Vector.
Subvector creates a new
vector, and returns a reference to the new vector, the contents
of which is formed in the following way. Let the contents of
the vector referred to by s.Vector be
(Ge0)(Ge1) ... (GeN).
Then the contents of the new vector is
obtained by removing the first s.Index terms from this sequence, and selecting
the first s.Len terms of the
remaining sequence.
The contents of the source vector remains unchanged.
SubvectorFill replaces
s.Len consecutive components in the
vector referred to by s.Vector with
e.Exp, starting from the component in
the position s.Index. The length of
the vector remains unchanged.
If the length of the vector is not sufficient for one of the
above operations to be performed, the vector remains unchanged,
and the value returned by the functions is $error(Fname "Index out of range") , where
Fname is the function's name.
If one of the above operations has to create a vector
contents whose length exceeds the size limit imposed by the
Refal Plus implementation, the vector remains unchanged, and
the value returned by the functions is $error(Fname "Size limit exceeded") , where
Fname is the function's name.