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.
Vectors are not resizeable. So a vector-append!
that extends a vector's size is not possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With