consC in Seasoned Schemer

39 Views Asked by At

The seasoned schemer on page 131 and 132 has the below definition of consC and deep.

(define consC 
  (let ((N 0)) 
   (lambda (x y) 
    (set! N (add1 N)) 
    (cons z y))))

(define deep
  (lambda (m)
    (if (zero? m)
      (quote pizza)
      (consC (deep (sub1 m))
        (quote ())))))

I have a problem that when deep use consC each time to recursion,why (let ((N 0)) don't reset N to 0?

0

There are 0 best solutions below