I don't know the underlying implementation of vectors in Scheme, hence not sure how to write a vector-append!
Prototype:
(define (vector-append! vect . vects)
; definition here
)
P.S. Preferred to use vector over list since vector-ref
is a constant time operation [src]
You can't resize a vector after its creation, so
vector-append!
can not be implemented as an in-place operation. What you can do, is create a new vector with size equal to the sum of all the subvectors' sizes, where the elements in all subvectors will be copied one after the other.Use
vector-grow
as the starting procedure, and work from there. You'll have to play a bit with indexes to get a working solution.