Hex Artifact Content
Not logged in

Artifact 00e666cce42dfd355e4a898bdac5174cf16849a2:


0000: 23 21 72 36 72 73 20 0a 3b 3b 3b 20 43 6f 70 79  #!r6rs .;;; Copy
0010: 72 69 67 68 74 20 28 43 29 20 50 68 69 6c 69 70  right (C) Philip
0020: 20 4c 2e 20 42 65 77 69 67 20 28 32 30 30 37 29   L. Bewig (2007)
0030: 2e 20 41 6c 6c 20 52 69 67 68 74 73 20 52 65 73  . All Rights Res
0040: 65 72 76 65 64 2e 0a 3b 3b 3b 20 50 65 72 6d 69  erved..;;; Permi
0050: 73 73 69 6f 6e 20 69 73 20 68 65 72 65 62 79 20  ssion is hereby 
0060: 67 72 61 6e 74 65 64 2c 20 66 72 65 65 20 6f 66  granted, free of
0070: 20 63 68 61 72 67 65 2c 20 74 6f 20 61 6e 79 20   charge, to any 
0080: 70 65 72 73 6f 6e 0a 3b 3b 3b 20 6f 62 74 61 69  person.;;; obtai
0090: 6e 69 6e 67 20 61 20 63 6f 70 79 20 6f 66 20 74  ning a copy of t
00a0: 68 69 73 20 73 6f 66 74 77 61 72 65 20 61 6e 64  his software and
00b0: 20 61 73 73 6f 63 69 61 74 65 64 20 64 6f 63 75   associated docu
00c0: 6d 65 6e 74 61 74 69 6f 6e 20 66 69 6c 65 73 0a  mentation files.
00d0: 3b 3b 3b 20 28 74 68 65 20 22 53 6f 66 74 77 61  ;;; (the "Softwa
00e0: 72 65 22 29 2c 20 74 6f 20 64 65 61 6c 20 69 6e  re"), to deal in
00f0: 20 74 68 65 20 53 6f 66 74 77 61 72 65 20 77 69   the Software wi
0100: 74 68 6f 75 74 20 72 65 73 74 72 69 63 74 69 6f  thout restrictio
0110: 6e 2c 0a 3b 3b 3b 20 69 6e 63 6c 75 64 69 6e 67  n,.;;; including
0120: 20 77 69 74 68 6f 75 74 20 6c 69 6d 69 74 61 74   without limitat
0130: 69 6f 6e 20 74 68 65 20 72 69 67 68 74 73 20 74  ion the rights t
0140: 6f 20 75 73 65 2c 20 63 6f 70 79 2c 20 6d 6f 64  o use, copy, mod
0150: 69 66 79 2c 20 6d 65 72 67 65 2c 0a 3b 3b 3b 20  ify, merge,.;;; 
0160: 70 75 62 6c 69 73 68 2c 20 64 69 73 74 72 69 62  publish, distrib
0170: 75 74 65 2c 20 73 75 62 6c 69 63 65 6e 73 65 2c  ute, sublicense,
0180: 20 61 6e 64 2f 6f 72 20 73 65 6c 6c 20 63 6f 70   and/or sell cop
0190: 69 65 73 20 6f 66 20 74 68 65 20 53 6f 66 74 77  ies of the Softw
01a0: 61 72 65 2c 0a 3b 3b 3b 20 61 6e 64 20 74 6f 20  are,.;;; and to 
01b0: 70 65 72 6d 69 74 20 70 65 72 73 6f 6e 73 20 74  permit persons t
01c0: 6f 20 77 68 6f 6d 20 74 68 65 20 53 6f 66 74 77  o whom the Softw
01d0: 61 72 65 20 69 73 20 66 75 72 6e 69 73 68 65 64  are is furnished
01e0: 20 74 6f 20 64 6f 20 73 6f 2c 0a 3b 3b 3b 20 73   to do so,.;;; s
01f0: 75 62 6a 65 63 74 20 74 6f 20 74 68 65 20 66 6f  ubject to the fo
0200: 6c 6c 6f 77 69 6e 67 20 63 6f 6e 64 69 74 69 6f  llowing conditio
0210: 6e 73 3a 0a 3b 3b 3b 20 0a 3b 3b 3b 20 54 68 65  ns:.;;; .;;; The
0220: 20 61 62 6f 76 65 20 63 6f 70 79 72 69 67 68 74   above copyright
0230: 20 6e 6f 74 69 63 65 20 61 6e 64 20 74 68 69 73   notice and this
0240: 20 70 65 72 6d 69 73 73 69 6f 6e 20 6e 6f 74 69   permission noti
0250: 63 65 20 73 68 61 6c 6c 20 62 65 0a 3b 3b 3b 20  ce shall be.;;; 
0260: 69 6e 63 6c 75 64 65 64 20 69 6e 20 61 6c 6c 20  included in all 
0270: 63 6f 70 69 65 73 20 6f 72 20 73 75 62 73 74 61  copies or substa
0280: 6e 74 69 61 6c 20 70 6f 72 74 69 6f 6e 73 20 6f  ntial portions o
0290: 66 20 74 68 65 20 53 6f 66 74 77 61 72 65 2e 0a  f the Software..
02a0: 3b 3b 3b 20 0a 3b 3b 3b 20 54 48 45 20 53 4f 46  ;;; .;;; THE SOF
02b0: 54 57 41 52 45 20 49 53 20 50 52 4f 56 49 44 45  TWARE IS PROVIDE
02c0: 44 20 22 41 53 20 49 53 22 2c 20 57 49 54 48 4f  D "AS IS", WITHO
02d0: 55 54 20 57 41 52 52 41 4e 54 59 20 4f 46 20 41  UT WARRANTY OF A
02e0: 4e 59 20 4b 49 4e 44 2c 0a 3b 3b 3b 20 45 58 50  NY KIND,.;;; EXP
02f0: 52 45 53 53 20 4f 52 20 49 4d 50 4c 49 45 44 2c  RESS OR IMPLIED,
0300: 20 49 4e 43 4c 55 44 49 4e 47 20 42 55 54 20 4e   INCLUDING BUT N
0310: 4f 54 20 4c 49 4d 49 54 45 44 20 54 4f 20 54 48  OT LIMITED TO TH
0320: 45 20 57 41 52 52 41 4e 54 49 45 53 20 4f 46 0a  E WARRANTIES OF.
0330: 3b 3b 3b 20 4d 45 52 43 48 41 4e 54 41 42 49 4c  ;;; MERCHANTABIL
0340: 49 54 59 2c 20 46 49 54 4e 45 53 53 20 46 4f 52  ITY, FITNESS FOR
0350: 20 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55   A PARTICULAR PU
0360: 52 50 4f 53 45 20 41 4e 44 0a 3b 3b 3b 20 4e 4f  RPOSE AND.;;; NO
0370: 4e 49 4e 46 52 49 4e 47 45 4d 45 4e 54 2e 20 49  NINFRINGEMENT. I
0380: 4e 20 4e 4f 20 45 56 45 4e 54 20 53 48 41 4c 4c  N NO EVENT SHALL
0390: 20 54 48 45 20 41 55 54 48 4f 52 53 20 4f 52 20   THE AUTHORS OR 
03a0: 43 4f 50 59 52 49 47 48 54 20 48 4f 4c 44 45 52  COPYRIGHT HOLDER
03b0: 53 0a 3b 3b 3b 20 42 45 20 4c 49 41 42 4c 45 20  S.;;; BE LIABLE 
03c0: 46 4f 52 20 41 4e 59 20 43 4c 41 49 4d 2c 20 44  FOR ANY CLAIM, D
03d0: 41 4d 41 47 45 53 20 4f 52 20 4f 54 48 45 52 20  AMAGES OR OTHER 
03e0: 4c 49 41 42 49 4c 49 54 59 2c 20 57 48 45 54 48  LIABILITY, WHETH
03f0: 45 52 20 49 4e 20 41 4e 0a 3b 3b 3b 20 41 43 54  ER IN AN.;;; ACT
0400: 49 4f 4e 20 4f 46 20 43 4f 4e 54 52 41 43 54 2c  ION OF CONTRACT,
0410: 20 54 4f 52 54 20 4f 52 20 4f 54 48 45 52 57 49   TORT OR OTHERWI
0420: 53 45 2c 20 41 52 49 53 49 4e 47 20 46 52 4f 4d  SE, ARISING FROM
0430: 2c 20 4f 55 54 20 4f 46 20 4f 52 20 49 4e 0a 3b  , OUT OF OR IN.;
0440: 3b 3b 20 43 4f 4e 4e 45 43 54 49 4f 4e 20 57 49  ;; CONNECTION WI
0450: 54 48 20 54 48 45 20 53 4f 46 54 57 41 52 45 20  TH THE SOFTWARE 
0460: 4f 52 20 54 48 45 20 55 53 45 20 4f 52 20 4f 54  OR THE USE OR OT
0470: 48 45 52 20 44 45 41 4c 49 4e 47 53 20 49 4e 20  HER DEALINGS IN 
0480: 54 48 45 0a 3b 3b 3b 20 53 4f 46 54 57 41 52 45  THE.;;; SOFTWARE
0490: 2e 0a 0a 28 6c 69 62 72 61 72 79 20 28 73 72 66  ...(library (srf
04a0: 69 20 73 34 31 20 73 74 72 65 61 6d 73 20 70 72  i s41 streams pr
04b0: 69 6d 69 74 69 76 65 29 0a 0a 20 20 28 65 78 70  imitive)..  (exp
04c0: 6f 72 74 20 73 74 72 65 61 6d 2d 6e 75 6c 6c 20  ort stream-null 
04d0: 73 74 72 65 61 6d 2d 63 6f 6e 73 20 73 74 72 65  stream-cons stre
04e0: 61 6d 3f 20 73 74 72 65 61 6d 2d 6e 75 6c 6c 3f  am? stream-null?
04f0: 20 73 74 72 65 61 6d 2d 70 61 69 72 3f 0a 20 20   stream-pair?.  
0500: 20 20 20 20 20 20 20 20 73 74 72 65 61 6d 2d 63          stream-c
0510: 61 72 20 73 74 72 65 61 6d 2d 63 64 72 20 73 74  ar stream-cdr st
0520: 72 65 61 6d 2d 6c 61 6d 62 64 61 29 0a 0a 20 20  ream-lambda)..  
0530: 28 69 6d 70 6f 72 74 20 28 72 6e 72 73 29 20 28  (import (rnrs) (
0540: 72 6e 72 73 20 6d 75 74 61 62 6c 65 2d 70 61 69  rnrs mutable-pai
0550: 72 73 29 29 0a 0a 20 20 28 64 65 66 69 6e 65 2d  rs))..  (define-
0560: 72 65 63 6f 72 64 2d 74 79 70 65 20 28 73 74 72  record-type (str
0570: 65 61 6d 2d 74 79 70 65 20 6d 61 6b 65 2d 73 74  eam-type make-st
0580: 72 65 61 6d 20 73 74 72 65 61 6d 3f 29 0a 20 20  ream stream?).  
0590: 20 20 28 66 69 65 6c 64 73 20 28 6d 75 74 61 62    (fields (mutab
05a0: 6c 65 20 62 6f 78 20 73 74 72 65 61 6d 2d 70 72  le box stream-pr
05b0: 6f 6d 69 73 65 20 73 74 72 65 61 6d 2d 70 72 6f  omise stream-pro
05c0: 6d 69 73 65 21 29 29 29 0a 0a 20 20 28 64 65 66  mise!)))..  (def
05d0: 69 6e 65 2d 73 79 6e 74 61 78 20 73 74 72 65 61  ine-syntax strea
05e0: 6d 2d 6c 61 7a 79 0a 20 20 20 20 28 73 79 6e 74  m-lazy.    (synt
05f0: 61 78 2d 72 75 6c 65 73 20 28 29 0a 20 20 20 20  ax-rules ().    
0600: 20 20 28 28 6c 61 7a 79 20 65 78 70 72 29 0a 20    ((lazy expr). 
0610: 20 20 20 20 20 20 20 28 6d 61 6b 65 2d 73 74 72         (make-str
0620: 65 61 6d 0a 20 20 20 20 20 20 20 20 20 20 28 63  eam.          (c
0630: 6f 6e 73 20 27 6c 61 7a 79 20 28 6c 61 6d 62 64  ons 'lazy (lambd
0640: 61 20 28 29 20 65 78 70 72 29 29 29 29 29 29 0a  a () expr)))))).
0650: 0a 20 20 28 64 65 66 69 6e 65 20 28 73 74 72 65  .  (define (stre
0660: 61 6d 2d 65 61 67 65 72 20 65 78 70 72 29 0a 20  am-eager expr). 
0670: 20 20 20 28 6d 61 6b 65 2d 73 74 72 65 61 6d 0a     (make-stream.
0680: 20 20 20 20 20 20 28 63 6f 6e 73 20 27 65 61 67        (cons 'eag
0690: 65 72 20 65 78 70 72 29 29 29 0a 0a 20 20 28 64  er expr)))..  (d
06a0: 65 66 69 6e 65 2d 73 79 6e 74 61 78 20 73 74 72  efine-syntax str
06b0: 65 61 6d 2d 64 65 6c 61 79 0a 20 20 20 20 28 73  eam-delay.    (s
06c0: 79 6e 74 61 78 2d 72 75 6c 65 73 20 28 29 0a 20  yntax-rules (). 
06d0: 20 20 20 20 20 28 28 73 74 72 65 61 6d 2d 64 65       ((stream-de
06e0: 6c 61 79 20 65 78 70 72 29 0a 20 20 20 20 20 20  lay expr).      
06f0: 20 20 28 73 74 72 65 61 6d 2d 6c 61 7a 79 20 28    (stream-lazy (
0700: 73 74 72 65 61 6d 2d 65 61 67 65 72 20 65 78 70  stream-eager exp
0710: 72 29 29 29 29 29 0a 0a 20 20 28 64 65 66 69 6e  r)))))..  (defin
0720: 65 20 28 73 74 72 65 61 6d 2d 66 6f 72 63 65 20  e (stream-force 
0730: 70 72 6f 6d 69 73 65 29 0a 20 20 20 20 28 6c 65  promise).    (le
0740: 74 20 28 28 63 6f 6e 74 65 6e 74 20 28 73 74 72  t ((content (str
0750: 65 61 6d 2d 70 72 6f 6d 69 73 65 20 70 72 6f 6d  eam-promise prom
0760: 69 73 65 29 29 29 0a 20 20 20 20 20 20 28 63 61  ise))).      (ca
0770: 73 65 20 28 63 61 72 20 63 6f 6e 74 65 6e 74 29  se (car content)
0780: 0a 20 20 20 20 20 20 20 20 28 28 65 61 67 65 72  .        ((eager
0790: 29 20 28 63 64 72 20 63 6f 6e 74 65 6e 74 29 29  ) (cdr content))
07a0: 0a 20 20 20 20 20 20 20 20 28 28 6c 61 7a 79 29  .        ((lazy)
07b0: 20 20 28 6c 65 74 2a 20 28 28 70 72 6f 6d 69 73    (let* ((promis
07c0: 65 2a 20 28 28 63 64 72 20 63 6f 6e 74 65 6e 74  e* ((cdr content
07d0: 29 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20  ))).            
07e0: 20 20 20 20 20 20 20 20 20 20 20 20 28 63 6f 6e              (con
07f0: 74 65 6e 74 20 20 28 73 74 72 65 61 6d 2d 70 72  tent  (stream-pr
0800: 6f 6d 69 73 65 20 70 72 6f 6d 69 73 65 29 29 29  omise promise)))
0810: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
0820: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 65 71      (if (not (eq
0830: 76 3f 20 28 63 61 72 20 63 6f 6e 74 65 6e 74 29  v? (car content)
0840: 20 27 65 61 67 65 72 29 29 0a 20 20 20 20 20 20   'eager)).      
0850: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0860: 20 28 62 65 67 69 6e 20 28 73 65 74 2d 63 61 72   (begin (set-car
0870: 21 20 63 6f 6e 74 65 6e 74 20 28 63 61 72 20 28  ! content (car (
0880: 73 74 72 65 61 6d 2d 70 72 6f 6d 69 73 65 20 70  stream-promise p
0890: 72 6f 6d 69 73 65 2a 29 29 29 0a 20 20 20 20 20  romise*))).     
08a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
08b0: 20 20 20 20 20 20 20 20 20 28 73 65 74 2d 63 64           (set-cd
08c0: 72 21 20 63 6f 6e 74 65 6e 74 20 28 63 64 72 20  r! content (cdr 
08d0: 28 73 74 72 65 61 6d 2d 70 72 6f 6d 69 73 65 20  (stream-promise 
08e0: 70 72 6f 6d 69 73 65 2a 29 29 29 0a 20 20 20 20  promise*))).    
08f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0900: 20 20 20 20 20 20 20 20 20 20 28 73 74 72 65 61            (strea
0910: 6d 2d 70 72 6f 6d 69 73 65 21 20 70 72 6f 6d 69  m-promise! promi
0920: 73 65 2a 20 63 6f 6e 74 65 6e 74 29 29 29 0a 20  se* content))). 
0930: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0940: 20 20 28 73 74 72 65 61 6d 2d 66 6f 72 63 65 20    (stream-force 
0950: 70 72 6f 6d 69 73 65 29 29 29 29 29 29 0a 0a 20  promise)))))).. 
0960: 20 28 64 65 66 69 6e 65 20 73 74 72 65 61 6d 2d   (define stream-
0970: 6e 75 6c 6c 20 28 73 74 72 65 61 6d 2d 64 65 6c  null (stream-del
0980: 61 79 20 28 63 6f 6e 73 20 27 73 74 72 65 61 6d  ay (cons 'stream
0990: 20 27 6e 75 6c 6c 29 29 29 0a 0a 20 20 28 64 65   'null)))..  (de
09a0: 66 69 6e 65 2d 72 65 63 6f 72 64 2d 74 79 70 65  fine-record-type
09b0: 20 28 73 74 72 65 61 6d 2d 70 61 72 65 2d 74 79   (stream-pare-ty
09c0: 70 65 20 6d 61 6b 65 2d 73 74 72 65 61 6d 2d 70  pe make-stream-p
09d0: 61 72 65 20 73 74 72 65 61 6d 2d 70 61 72 65 3f  are stream-pare?
09e0: 29 0a 20 20 20 20 28 66 69 65 6c 64 73 20 28 69  ).    (fields (i
09f0: 6d 6d 75 74 61 62 6c 65 20 6b 61 72 20 73 74 72  mmutable kar str
0a00: 65 61 6d 2d 6b 61 72 29 20 28 69 6d 6d 75 74 61  eam-kar) (immuta
0a10: 62 6c 65 20 6b 64 72 20 73 74 72 65 61 6d 2d 6b  ble kdr stream-k
0a20: 64 72 29 29 29 0a 0a 20 20 28 64 65 66 69 6e 65  dr)))..  (define
0a30: 20 28 73 74 72 65 61 6d 2d 70 61 69 72 3f 20 6f   (stream-pair? o
0a40: 62 6a 29 0a 20 20 20 20 28 61 6e 64 20 28 73 74  bj).    (and (st
0a50: 72 65 61 6d 3f 20 6f 62 6a 29 20 28 73 74 72 65  ream? obj) (stre
0a60: 61 6d 2d 70 61 72 65 3f 20 28 73 74 72 65 61 6d  am-pare? (stream
0a70: 2d 66 6f 72 63 65 20 6f 62 6a 29 29 29 29 0a 0a  -force obj))))..
0a80: 20 20 28 64 65 66 69 6e 65 20 28 73 74 72 65 61    (define (strea
0a90: 6d 2d 6e 75 6c 6c 3f 20 6f 62 6a 29 0a 20 20 20  m-null? obj).   
0aa0: 20 28 61 6e 64 20 28 73 74 72 65 61 6d 3f 20 6f   (and (stream? o
0ab0: 62 6a 29 0a 20 20 20 20 20 20 20 20 20 28 65 71  bj).         (eq
0ac0: 76 3f 20 28 73 74 72 65 61 6d 2d 66 6f 72 63 65  v? (stream-force
0ad0: 20 6f 62 6a 29 0a 20 20 20 20 20 20 20 20 20 20   obj).          
0ae0: 20 20 20 20 20 28 73 74 72 65 61 6d 2d 66 6f 72       (stream-for
0af0: 63 65 20 73 74 72 65 61 6d 2d 6e 75 6c 6c 29 29  ce stream-null))
0b00: 29 29 0a 0a 20 20 28 64 65 66 69 6e 65 2d 73 79  ))..  (define-sy
0b10: 6e 74 61 78 20 73 74 72 65 61 6d 2d 63 6f 6e 73  ntax stream-cons
0b20: 0a 20 20 20 20 28 73 79 6e 74 61 78 2d 72 75 6c  .    (syntax-rul
0b30: 65 73 20 28 29 0a 20 20 20 20 20 20 28 28 73 74  es ().      ((st
0b40: 72 65 61 6d 2d 63 6f 6e 73 20 6f 62 6a 20 73 74  ream-cons obj st
0b50: 72 6d 29 0a 20 20 20 20 20 20 20 20 28 73 74 72  rm).        (str
0b60: 65 61 6d 2d 64 65 6c 61 79 20 28 6d 61 6b 65 2d  eam-delay (make-
0b70: 73 74 72 65 61 6d 2d 70 61 72 65 20 28 73 74 72  stream-pare (str
0b80: 65 61 6d 2d 64 65 6c 61 79 20 6f 62 6a 29 20 28  eam-delay obj) (
0b90: 73 74 72 65 61 6d 2d 6c 61 7a 79 20 73 74 72 6d  stream-lazy strm
0ba0: 29 29 29 29 29 29 0a 0a 20 20 28 64 65 66 69 6e  ))))))..  (defin
0bb0: 65 20 28 73 74 72 65 61 6d 2d 63 61 72 20 73 74  e (stream-car st
0bc0: 72 6d 29 0a 20 20 20 20 28 63 6f 6e 64 20 28 28  rm).    (cond ((
0bd0: 6e 6f 74 20 28 73 74 72 65 61 6d 3f 20 73 74 72  not (stream? str
0be0: 6d 29 29 20 28 65 72 72 6f 72 20 27 73 74 72 65  m)) (error 'stre
0bf0: 61 6d 2d 63 61 72 20 22 6e 6f 6e 2d 73 74 72 65  am-car "non-stre
0c00: 61 6d 22 29 29 0a 20 20 20 20 20 20 20 20 20 20  am")).          
0c10: 28 28 73 74 72 65 61 6d 2d 6e 75 6c 6c 3f 20 73  ((stream-null? s
0c20: 74 72 6d 29 20 28 65 72 72 6f 72 20 27 73 74 72  trm) (error 'str
0c30: 65 61 6d 2d 63 61 72 20 22 6e 75 6c 6c 20 73 74  eam-car "null st
0c40: 72 65 61 6d 22 29 29 0a 20 20 20 20 20 20 20 20  ream")).        
0c50: 20 20 28 65 6c 73 65 20 28 73 74 72 65 61 6d 2d    (else (stream-
0c60: 66 6f 72 63 65 20 28 73 74 72 65 61 6d 2d 6b 61  force (stream-ka
0c70: 72 20 28 73 74 72 65 61 6d 2d 66 6f 72 63 65 20  r (stream-force 
0c80: 73 74 72 6d 29 29 29 29 29 29 0a 0a 20 20 28 64  strm))))))..  (d
0c90: 65 66 69 6e 65 20 28 73 74 72 65 61 6d 2d 63 64  efine (stream-cd
0ca0: 72 20 73 74 72 6d 29 0a 20 20 20 20 28 63 6f 6e  r strm).    (con
0cb0: 64 20 28 28 6e 6f 74 20 28 73 74 72 65 61 6d 3f  d ((not (stream?
0cc0: 20 73 74 72 6d 29 29 20 28 65 72 72 6f 72 20 27   strm)) (error '
0cd0: 73 74 72 65 61 6d 2d 63 64 72 20 22 6e 6f 6e 2d  stream-cdr "non-
0ce0: 73 74 72 65 61 6d 22 29 29 0a 20 20 20 20 20 20  stream")).      
0cf0: 20 20 20 20 28 28 73 74 72 65 61 6d 2d 6e 75 6c      ((stream-nul
0d00: 6c 3f 20 73 74 72 6d 29 20 28 65 72 72 6f 72 20  l? strm) (error 
0d10: 27 73 74 72 65 61 6d 2d 63 64 72 20 22 6e 75 6c  'stream-cdr "nul
0d20: 6c 20 73 74 72 65 61 6d 22 29 29 0a 20 20 20 20  l stream")).    
0d30: 20 20 20 20 20 20 28 65 6c 73 65 20 28 73 74 72        (else (str
0d40: 65 61 6d 2d 6b 64 72 20 28 73 74 72 65 61 6d 2d  eam-kdr (stream-
0d50: 66 6f 72 63 65 20 73 74 72 6d 29 29 29 29 29 0a  force strm))))).
0d60: 0a 20 20 28 64 65 66 69 6e 65 2d 73 79 6e 74 61  .  (define-synta
0d70: 78 20 73 74 72 65 61 6d 2d 6c 61 6d 62 64 61 0a  x stream-lambda.
0d80: 20 20 20 20 28 73 79 6e 74 61 78 2d 72 75 6c 65      (syntax-rule
0d90: 73 20 28 29 0a 20 20 20 20 20 20 28 28 73 74 72  s ().      ((str
0da0: 65 61 6d 2d 6c 61 6d 62 64 61 20 66 6f 72 6d 61  eam-lambda forma
0db0: 6c 73 20 62 6f 64 79 30 20 62 6f 64 79 31 20 2e  ls body0 body1 .
0dc0: 2e 2e 29 0a 20 20 20 20 20 20 20 20 28 6c 61 6d  ..).        (lam
0dd0: 62 64 61 20 66 6f 72 6d 61 6c 73 20 28 73 74 72  bda formals (str
0de0: 65 61 6d 2d 6c 61 7a 79 20 28 6c 65 74 20 28 29  eam-lazy (let ()
0df0: 20 62 6f 64 79 30 20 62 6f 64 79 31 20 2e 2e 2e   body0 body1 ...
0e00: 29 29 29 29 29 29 29 0a                          ))))))).