20.3 General X-Vector Operations
An x-vector is either a vector, string, word-vector, or byte-vector. Each may have several
elements, accessed by an integer index. A valid index for an x-vector X is from 0 to (size X).
Thus an x-vector X will have (add1 (size X)) elements. The functions described in this section
may also be applied to lists.
(size X:x-vector): integer expr
Returns the size of x-vector X, the size is the index of the last element.
(indx X:x-vector I:integer): any expr
Access the I’th element of an x-vector. An error occurs if I is either negative
or exceeds the size of X.
⋆⋆⋆⋆⋆ Index ‘I' out of range for X in INDX
(setindx X:x-vector I:integer A:any): any expr
Define A to be the I’th element of X. If the index I is outside the range of
X then it is an error (see indx for a description of the message).
(sub X:x-vector B:integer S:integer): x-vector expr
Extract a subrange of an x-vector, starting at B, producing a new x-vector
of size S. Note that an x-vector of size 0 has one entry.
(setsub X:x-vector I1:integer S:integer Y:x-vector):x-vector expr
Store subrange of Y of size S into X starting at I1. Returns Y.
(subseq X:x-vector LO:integer HI:integer): x-vector expr
Returns an x-vector whose size is (sub1 (- HI LO)), beginning with the
element of X with index LO. In other words, returns the subsequence of X
starting at LO and ending just before HI.
1 lisp> (setq a '[0 1 2 3 4 5 6])
[0 1 2 3 4 5 6]
2 lisp> (subseq a 4 6)
(setsubseq Y:x-vector):Y:x-vector expr
The size of Y must be (sub1 (- HI LO)) and Y must be the same type of
x-vector as X. Elements LO through (sub1 HI) in X are replaced by the
elements of Y. Y is returned and X is changed destructively.
1 lisp> (setq a "0123456")
2 lisp> (setsubseq a 3 7 "ABCD")
3 lisp> A
(concat X:x-vector Y:x-vector): x-vector expr
Concatenate 2 x-vectors. Currently they must be of same type.
(totalcopy S:any): any expr
Returns a unique copy of the entire structure, i.e., it copies everything
for which storage is allocated - everything but inums and ids. Like copy
(Chapter 5) totalcopy will not terminate when applied to circular structures.
1 lisp> (setq x '("ONE" 2)
1 lisp> y (totalcopy x)
1 lisp> z (copy x))
2 lisp> (eq (first x) (first y))
3 lisp> (eq (first x) (first z))