summary refs log tree commit diff
path: root/implementation/flexvectors-body2.scm
diff options
context:
space:
mode:
Diffstat (limited to 'implementation/flexvectors-body2.scm')
-rw-r--r--implementation/flexvectors-body2.scm10
1 files changed, 10 insertions, 0 deletions
diff --git a/implementation/flexvectors-body2.scm b/implementation/flexvectors-body2.scm
index ba3e2f5..6f37efe 100644
--- a/implementation/flexvectors-body2.scm
+++ b/implementation/flexvectors-body2.scm
@@ -389,3 +389,13 @@
 (define (generator->flexvector g)
   (assume (procedure? g))
   (flexvector-unfold eof-object? (lambda (x) x) (lambda (_) (g)) (g)))
+
+(define (flexvector->generator fv)
+  (assume (flexvector? fv))
+  (let ((i 0))
+    (lambda ()
+      (if (< i (flexvector-length fv))
+        (let ((element (flexvector-ref fv i)))
+          (set! i (+ i 1))
+          element)
+        (eof-object)))))