From 953f3ada23f5715d607b5df095d5f6764241d8f9 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 26 May 2024 22:00:43 +0900 Subject: [PATCH] allow noop (index-rotate n n) Closes #965. --- lib/srfi/231/base.scm | 2 +- lib/srfi/231/test.sld | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/srfi/231/base.scm b/lib/srfi/231/base.scm index 9fc483fe..5b09a38b 100644 --- a/lib/srfi/231/base.scm +++ b/lib/srfi/231/base.scm @@ -24,7 +24,7 @@ (define (index-rotate n k) (assert (and (exact-integer? n) (exact-integer? k) - (< -1 k n))) + (<= 0 k n))) (list->vector (append (iota (- n k) k) (iota k)))) (define (index-first n k) diff --git a/lib/srfi/231/test.sld b/lib/srfi/231/test.sld index b9031901..93c531f1 100644 --- a/lib/srfi/231/test.sld +++ b/lib/srfi/231/test.sld @@ -926,6 +926,7 @@ (test-error (index-rotate 0 -2)) (test-error (index-rotate 3 5)) (test '#(3 4 0 1 2) (index-rotate 5 3)) + (test '#(0 1 2 3 4) (index-rotate 5 5)) (test-error (index-swap 'a 3 0)) (test-error (index-swap 5 'a 0))