diff options
author | Adam R. Nelson <adam@nels.onl> | 2021-03-11 22:42:57 -0500 |
---|---|---|
committer | Arthur A. Gleckler <srfi@speechcode.com> | 2021-03-11 21:00:45 -0800 |
commit | 368abdee7869e99fa287ec2e6b099ee4584372e5 (patch) | |
tree | e32a0fad8d4d2dc4b4b8cf7ec53915e9aad87b19 /implementation/flexvectors-body2.scm | |
parent | 983ee1afbab1108c3608ba4228824f6944301d69 (diff) | |
download | srfi-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.scm | 10 |
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))))) |