From 48faa9ac986ea1cd9e94dbac9e0fdd8e953b62f0 Mon Sep 17 00:00:00 2001 From: stibear Date: Wed, 16 Jul 2014 16:46:22 +0900 Subject: [PATCH 1/2] fixed vector-map/map! --- contrib/10.srfi/srfi/43.scm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/contrib/10.srfi/srfi/43.scm b/contrib/10.srfi/srfi/43.scm index 88ebc083..993a0aa1 100644 --- a/contrib/10.srfi/srfi/43.scm +++ b/contrib/10.srfi/srfi/43.scm @@ -92,16 +92,28 @@ (map (lambda (v) (vector-ref v count)) vects)) (- count 1)))))) - (define (vector-map! f vec . vects) + (define (vector-map f vec . vects) (let* ((vects (cons vec vects)) (veclen (apply min (map vector-length vects))) (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)) (if (< count veclen) (begin (vector-set! vec count - (apply f (map (lambda (v) (vector-ref v count)) - vects))) + (apply f count (map (lambda (v) (vector-ref v count)) + vects))) (rec (+ 1 count))))))) (define (vector-count pred? vec . vects) From 52624460cdf3db74423467f5db9c1193daddbd05 Mon Sep 17 00:00:00 2001 From: OGINO Masanori Date: Wed, 13 May 2015 12:08:38 +0900 Subject: [PATCH 2/2] Don't import vector-map from R7RS in SRFI 43. Signed-off-by: OGINO Masanori --- contrib/10.srfi/srfi/43.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/10.srfi/srfi/43.scm b/contrib/10.srfi/srfi/43.scm index 993a0aa1..13e5341c 100644 --- a/contrib/10.srfi/srfi/43.scm +++ b/contrib/10.srfi/srfi/43.scm @@ -1,5 +1,5 @@ (define-library (srfi 43) - (import (scheme base) + (import (except (scheme base) vector-map) (srfi 8)) ;; # Constructors