Lecture 5 - slide 24 : 26 |
(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)))))