From 3f465fd69a6ed5635950f5be0b2fbf35b7856b0a Mon Sep 17 00:00:00 2001 From: Jeremy Steward Date: Fri, 2 Sep 2016 15:40:59 -0600 Subject: [PATCH] Fixes vector-cumulate to have same signature as fold Cumulation is really just accumulating the stepwise results of fold into a single collection (in this case, a vector). It makes more sense to keep the argument order this way (with knil first) as it matches the API for fold / vector-fold, which means one can switch between them as they choose. After talking about this with John Cowan, he also mentioned that the previous argument order (e.g. proc vec knil) is an error and it should have been (vector-cumulate proc knil vec) from the beginning. This should correct the issue in both the code and the main SRFI document. --- srfi-133.html | 2 +- vectors/vectors-impl.scm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/srfi-133.html b/srfi-133.html index c296b93..431ee69 100644 --- a/srfi-133.html +++ b/srfi-133.html @@ -1464,7 +1464,7 @@

5.4. Iteration

- (vector-cumulate f vec knil) + (vector-cumulate f knil vec) -> vector
diff --git a/vectors/vectors-impl.scm b/vectors/vectors-impl.scm index 9eaabd0..9b798e0 100644 --- a/vectors/vectors-impl.scm +++ b/vectors/vectors-impl.scm @@ -917,13 +917,13 @@ vector-count) (cons vec vectors))))) -;;; (VECTOR-CUMULATE ) +;;; (VECTOR-CUMULATE ) ;;; -> vector ;;; Returns a ly allocated vector with the same length as ;;; . Each element of is set to the result of invoking on ;;; [i-1] and [i], except that for the first call on , the first ;;; argument is . The vector is returned. -(define (vector-cumulate f vec knil) +(define (vector-cumulate f knil vec) (let* ((len (vector-length vec)) (result (make-vector len))) (let loop ((i 0) (left knil))