summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2020-09-29 16:44:56 -0400
committerDavid Thompson <dthompson2@worcester.edu>2020-09-29 16:44:56 -0400
commitc2f39ea3e873ad9663c28c4c870ba47cda32497e (patch)
tree77a453e1017cdd8bdb1bdbe75b7dcc853fb43024
parent35f2afb2d4d3adc72d83fbc9582d8dc9bfee0ab0 (diff)
array-list: Handle deletions during iteration a bit better.
-rw-r--r--chickadee/array-list.scm10
1 files changed, 4 insertions, 6 deletions
diff --git a/chickadee/array-list.scm b/chickadee/array-list.scm
index e09cded..6c1e6f1 100644
--- a/chickadee/array-list.scm
+++ b/chickadee/array-list.scm
@@ -139,18 +139,16 @@
*unspecified*)
(define (array-list-for-each proc array-list)
- (let ((size (array-list-size array-list))
- (vec (array-list-vector array-list)))
+ (let ((vec (array-list-vector array-list)))
(let loop ((i 0))
- (when (< i size)
+ (when (< i (array-list-size array-list))
(proc i (vector-ref vec i))
(loop (1+ i))))))
(define (array-list-fold proc init array-list)
- (let ((size (array-list-size array-list))
- (vec (array-list-vector array-list)))
+ (let ((vec (array-list-vector array-list)))
(let loop ((i 0)
(prev init))
- (if (< i size)
+ (if (< i (size (array-list-size array-list)))
(loop (1+ i) (proc i (vector-ref vec i) prev))
prev))))