Next: , Previous: , Up: vectors   [Index]


24.14 Replicate and rotate

Function: %xsubvector from to vec start past
Macro: xsubvector V from to

Extended subvector procedure replicating the selected subvector “up and down” index space, in both the positive and negative directions.

The call:

(%xsubvector from to '#(#\a #\b #\c #\d #\e #\f #\g) 3 6)

selects the subvector #(#\d #\e #\f) and defines the conceptual bidirectionally–infinite vector:

...  e  f  d  e  f  d  e  f  d  e  f ...
... -5 -4 -3 -2 -1  0 +1 +2 +3 +4 +5 ...
                    ^

that is #(#\d #\e #\f) repeated in both directions. %xsubvector returns the subvector of this vector beginning at index from, and ending at to.

We can use this function to perform a variety of tasks:

Note that:

It is an error if start equals past.

Function: xvector-xcopy! from to target target-start source source-start source-past
Macro: vector-xcopy! target-S source-S from to

Exactly the same as %xsubvector, but the extracted text is written into the selected subvector of target.

This operation is not defined if (eq? target start); we cannot copy a vector on top of itself.


Next: , Previous: , Up: vectors   [Index]