diff options
| author | Mike Vink <mike1994vink@gmail.com> | 2023-07-07 15:10:11 +0200 |
|---|---|---|
| committer | Mike Vink <mike1994vink@gmail.com> | 2023-07-07 15:10:11 +0200 |
| commit | 9cf86f51ee4dd078afadc45b8eb253bf28cf5241 (patch) | |
| tree | b26ade0ec17df582777bf9193ad8eae4f6c0e6ee /shared/sicp-stream.rkt | |
| parent | a8a8e239968d45cc2539b6a55f4dcde04f5543fd (diff) | |
Diffstat (limited to 'shared/sicp-stream.rkt')
| -rw-r--r-- | shared/sicp-stream.rkt | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/shared/sicp-stream.rkt b/shared/sicp-stream.rkt index e7a28d0..c695df7 100644 --- a/shared/sicp-stream.rkt +++ b/shared/sicp-stream.rkt @@ -9,6 +9,7 @@ display-line show display-stream + display-stream-until stream-ref stream-for-each stream-enumerate-interval @@ -27,6 +28,12 @@ (define (display-line x) (newline) (display x)) (define (show x) (display-line x) x) (define (display-stream s) (stream-for-each display-line s)) +(define (display-stream-until s until) + (cond ((< until 0) 'done) + ((stream-null? s) 'done) + (else (begin + (display-line (stream-car s)) + (display-stream-until (stream-cdr s) (- until 1)))))) (define (stream-ref s n) (if (= n 0) |
