; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010
; See the LICENSE file of the S9fES package for terms of use
;
; (vector-map! procedure^1 vector)  ==>  unspecific
;
; Destructively map a procedure over a vector, changing each member
; of the vector to the value of the procedure call.
;
; Example:   (let ((v (vector 1 2 3)))
;              (vector-map! - v)
;              v)                       ==>  #(-1 -2 -3)

(define (vector-map! f v)
  (let ((k (vector-length v)))
    (do ((i 0 (+ 1 i)))
        ((>= i k))
      (vector-set! v i (f (vector-ref v i))))))
