summary refs log tree commit diff
path: root/implementation/flexvectors-body2.scm
diff options
context:
space:
mode:
authorAdam R. Nelson <adam@nels.onl>2021-03-11 22:42:57 -0500
committerArthur A. Gleckler <srfi@speechcode.com>2021-03-11 21:00:45 -0800
commit368abdee7869e99fa287ec2e6b099ee4584372e5 (patch)
treee32a0fad8d4d2dc4b4b8cf7ec53915e9aad87b19 /implementation/flexvectors-body2.scm
parent983ee1afbab1108c3608ba4228824f6944301d69 (diff)
downloadsrfi-214-368abdee7869e99fa287ec2e6b099ee4584372e5.tar.gz
srfi-214-368abdee7869e99fa287ec2e6b099ee4584372e5.tar.xz
srfi-214-368abdee7869e99fa287ec2e6b099ee4584372e5.zip
last-minute updates: clarify some documentation, add flexvector->generator
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)))))