diff --git a/knots/parallelism.scm b/knots/parallelism.scm index 9331757..8f3ec39 100644 --- a/knots/parallelism.scm +++ b/knots/parallelism.scm @@ -79,7 +79,10 @@ (define result-vec (make-vector vecs-length)) - (let loop ((next-to-process-index 0) + (let loop ((next-to-process-index + (if (= 0 vecs-length) + #f + 0)) (channel-indexes '())) (if (and (eq? #f next-to-process-index) (null? channel-indexes)) diff --git a/tests/parallelism.scm b/tests/parallelism.scm index 0901b3c..7d8dea7 100644 --- a/tests/parallelism.scm +++ b/tests/parallelism.scm @@ -24,6 +24,16 @@ 100 (iota 34)))))) +;; Test fibers-map with an empty list +(run-fibers-for-tests + (lambda () + (fibers-map identity '()))) + +;; Test fibers-map with an empty vector +(run-fibers-for-tests + (lambda () + (fibers-map identity #()))) + ;; Test fibers-map with vectors (run-fibers-for-tests (lambda () @@ -43,4 +53,11 @@ (* 2 i)) (iota 34)))) +;; Test fibers-map-with-progress with an empty list +(run-fibers-for-tests + (lambda () + (fibers-map-with-progress + identity + '(())))) + (display "parallelism test finished successfully\n")