Implement till 3.66

This commit is contained in:
2021-01-05 09:44:02 -05:00
parent aab9d1bec3
commit cce800e61c
3 changed files with 130 additions and 25 deletions

View File

@@ -68,4 +68,33 @@
(display x)
(newline))
(define (take n xs)
(if (= n 0)
'()
(cons (stream-car xs)
(take (- n 1) (stream-cdr xs)))))
(define (display-stream s)
(stream-for-each display-line s))
(define (show x)
(display-line x)
x)
(define (stream-ref s n)
(if (= n 0)
(stream-car s)
(stream-ref (stream-cdr s) (- n 1))))
(define (partial-sums xs)
(cons-stream (stream-car xs)
(add-streams (partial-sums xs)
(stream-cdr xs))))
(define (scale-stream stream factor)
(stream-map (lambda (x) (* x factor)) stream))
(define (add-streams s1 s2)
(stream-map + s1 s2))
'util-loaded