16 hours ago
my attempt to do the exercises in sicp.
Wednesday, December 15, 2010
sicp exercise 3.53
;; Exercise 3.53. Without running the program, describe the elements of the stream defined by
;; (define s (cons-stream 1 (add-streams s s)))
(define (add-streams s1 s2)
(stream-map + s1 s2))
(define s (cons-stream 1 (add-streams s s)))
(newline)
(display (stream-ref s 2)) (newline)
(display (stream-ref s 3)) (newline)
(display (stream-ref s 4)) (newline)
(display (stream-ref s 5)) (newline)
(display (stream-ref s 6)) (newline)
(display (stream-ref s 7)) (newline)
;; Output
; 4
; 8
; 16
; 32
; 64
; 128
;... done
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment