regarding to SICP 3.5
my own implementation is as following
(define (delay exp) (lambda () exp))
(define (force delayed-obj)
(delayed-obj))
(define (cons-stream a b) (cons a (delay b)))
(define (stream-car stream) (car stream))
(define (stream-cdr stream) (force (cdr stream)))
(define (take n stream)
(if (= n 0)
(print "0")
(begin (take (- n 1) (stream-cdr stream))
(print n))))
(define (make-stream-enum-interval low high)
(if (> low high)
'()
(begin (print low) (cons-stream low (make-stream-enum-interval (+ low 1) high)))))
actually I found it's not really delayed. when I execute (define range-10-to-100 (make-stream-enum-interval 10 100)). I expect to see only 10 is print in the console. while it's 10.....100
is there anything wrong with my code? Or, if print 10...100 is necessary, then we can say the structure is (cons 10 (delay cons 11 (delay cons 12 (delay ....100))) if so, then we need more memory?