summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-03-05 08:27:38 -0500
committerDavid Thompson <dthompson2@worcester.edu>2021-03-05 08:27:38 -0500
commit4e25e065a41d88ae9b58378957c8c6de9b7545c6 (patch)
tree78e405b944ec913ef557c8d215064a78d33edcad
parent99565fd881b722599d43e515d80bc3df8d249e45 (diff)
utils: Handle negative increment in for-range.
-rw-r--r--chickadee/utils.scm5
1 files changed, 3 insertions, 2 deletions
diff --git a/chickadee/utils.scm b/chickadee/utils.scm
index e2a20c1..8869e8d 100644
--- a/chickadee/utils.scm
+++ b/chickadee/utils.scm
@@ -40,11 +40,12 @@
(e end)
(reverse? (< e s))
(start* (if reverse? e s))
- (end* (if reverse? s e)))
+ (end* (if reverse? s e))
+ (inc* (abs inc)))
(let loop ((var start*))
(when (< var end*)
body ...
- (loop (+ var inc))))))
+ (loop (+ var inc*))))))
((_ ((var end start)) body ...)
(for-range ((var end start 1)) body ...))
((_ ((var end)) body ...)