The functions stream-section and add-streams. | Lecture 5 - slide 24 : 26 Program 1 |
(define (stream-section n stream) (cond ((= n 0) '()) (else (cons (head stream) (stream-section (- n 1) (tail stream)))))) (define (add-streams s1 s2) (let ((h1 (head s1)) (h2 (head s2))) (cons-stream (+ h1 h2) (add-streams (tail s1) (tail s2)))))