- (map stream-cdr streams))))
-
-(define (stream-for-each f stream . rest)
- (if (null? rest) ;fast path
- (stream-for-each-one f stream)
- (stream-for-each-many f (cons stream rest))))
-
-(define (stream-for-each-one f stream)
- (if (not (stream-null? stream))
- (begin
- (f (stream-car stream))
- (stream-for-each-one f (stream-cdr stream)))))
-
-(define (stream-for-each-many f streams)
- (if (not (or-map stream-null? streams))
- (begin
- (apply f (map stream-car streams))
- (stream-for-each-many f (map stream-cdr streams)))))
-
-(define (stream-map f stream . rest)
- "Returns a newly allocated stream, each element being the result of
-invoking F with the corresponding elements of the STREAMs
-as its arguments."
- (if (null? rest) ;fast path
- (make-stream (lambda (s)
- (or (stream-null? s)
- (cons (f (stream-car s)) (stream-cdr s))))
- stream)
- (make-stream (lambda (streams)
- (or (or-map stream-null? streams)
- (cons (apply f (map stream-car streams))
- (map stream-cdr streams))))
- (cons stream rest))))