Skip to content

Commit

Permalink
adding streams
Browse files Browse the repository at this point in the history
  • Loading branch information
psholtz committed Feb 20, 2015
1 parent 9583321 commit 2468444
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Section-3.5/mit-scheme/exercise3-51.scm
@@ -0,0 +1,41 @@
;;
;; [working]
;;

;;
;; Define the supporting stream procedures:
;;
(define (stream-enumerate-interval low high)
(if (> low high)
the-empty-stream
(cons-stream
low
(stream-enumerate-interval (+ low 1) high))))

(define (display-line x)
(newline)
(display x))

;;
;; Define the "show" procedure:
;;
(define (show x)
(display-line x)
x)

;;
;; We evaluate the first expression:
;;
(define x (stream-map show (stream-enumerate-interval 0 10)))

;; [work]

;;
;; We evaluate the second expression:
;;
(stream-ref x 5)

;;
;; We evaluate the third expression:
;;
(stream-ref x 7)

0 comments on commit 2468444

Please sign in to comment.