fixed vector-map/map!
This commit is contained in:
parent
a8520fe595
commit
48faa9ac98
|
@ -92,16 +92,28 @@
|
||||||
(map (lambda (v) (vector-ref v count)) vects))
|
(map (lambda (v) (vector-ref v count)) vects))
|
||||||
(- count 1))))))
|
(- count 1))))))
|
||||||
|
|
||||||
(define (vector-map! f vec . vects)
|
(define (vector-map f vec . vects)
|
||||||
(let* ((vects (cons vec vects))
|
(let* ((vects (cons vec vects))
|
||||||
(veclen (apply min (map vector-length vects)))
|
(veclen (apply min (map vector-length vects)))
|
||||||
(new-vect (make-vector veclen)))
|
(new-vect (make-vector veclen)))
|
||||||
|
(let rec ((count 0))
|
||||||
|
(if (= count veclen)
|
||||||
|
new-vect
|
||||||
|
(begin
|
||||||
|
(vector-set! new-vect count
|
||||||
|
(apply f count (map (lambda (v) (vector-ref v count))
|
||||||
|
vects)))
|
||||||
|
(rec (+ 1 count)))))))
|
||||||
|
|
||||||
|
(define (vector-map! f vec . vects)
|
||||||
|
(let* ((vects (cons vec vects))
|
||||||
|
(veclen (apply min (map vector-length vects))))
|
||||||
(let rec ((count 0))
|
(let rec ((count 0))
|
||||||
(if (< count veclen)
|
(if (< count veclen)
|
||||||
(begin
|
(begin
|
||||||
(vector-set! vec count
|
(vector-set! vec count
|
||||||
(apply f (map (lambda (v) (vector-ref v count))
|
(apply f count (map (lambda (v) (vector-ref v count))
|
||||||
vects)))
|
vects)))
|
||||||
(rec (+ 1 count)))))))
|
(rec (+ 1 count)))))))
|
||||||
|
|
||||||
(define (vector-count pred? vec . vects)
|
(define (vector-count pred? vec . vects)
|
||||||
|
|
Loading…
Reference in New Issue