Next: srfi streams derived, Previous: srfi streams primitive, Up: srfi streams [Index]
(define strm123 (stream-cons 1 (stream-cons 2 (stream-cons 3 stream-null)))) (stream-car strm123) => 1 (stream-car (stream-cdr strm123) => 2 (stream-pair? (stream-cdr (stream-cons (/ 1 0) stream-null))) => #f (stream? (list 1 2 3)) => #f (define iter (stream-lambda (f x) (stream-cons x (iter f (f x))))) (define nats (iter (lambda (x) (+ x 1)) 0)) (stream-car (stream-cdr nats)) => 1 (define stream-add (stream-lambda (s1 s2) (stream-cons (+ (stream-car s1) (stream-car s2)) (stream-add (stream-cdr s1) (stream-cdr s2))))) (define evens (stream-add nats nats)) (stream-car evens) => 0 (stream-car (stream-cdr evens)) => 2 (stream-car (stream-cdr (stream-cdr evens))) => 4