Usually '!' implies a destructive operation on the Scheme. You have not made it clear that you want a destructive implementation. I will give both of you, it seems. First a non-destructive option, simply:
(define (vector-append! vect . vects) (list->vector (apply append (map vector->list (cons vect vects)))))
Now for the mutable, you will need your own vector abstraction, because the Scheme vectors are immutable in length. Do not let this distract you; if you need it, you need it.
(define (my-vector . values) (cons 'MY-VECTOR (list->vector values))) (define my-vector-values cdr) ; private (define (my-vector-ref vect index) (vector-ref (my-vector-values vect) index)) (define (my-vector-append! vect . vects) (set-cdr! vect (apply vector-append! (map my-vector-values (cons vect vects)))))
and then some helpers for your new abstraction:
(define (list->my-vector list) (cons 'MY-VECTOR (list->vector list))) (define (vector->my-vector vector) (cons 'MY-VECTOR vector) ; maybe ;; etc
source share