1.3.2 let

(define (square x)
  (* x x))

(define (f x y)
  (define (f-helper a b)
    (+ (* x (square a))
       (* y b)
       (* a b)))
  (f-helper (+ 1 (* x y))
            (- 1 y)))

(f 1 2)

(define (f-lambda x y)
  ((lambda (a b)
    (+ (* x (square a))
       (* y b)
       (* a b)))
  (+ 1 (* x y))
  (- 1 y)
  )
  )

(f-lambda 1 2)

(define (f-let x y)
  (let ((a (+ 1 (* x y)))
        (b (- 1 y)))
    (+ (* x (square a))
       (* y b)
       (* a b))))

(f-let 1 2)

  

(define x 5)

(+ (let ((x 3))
     (+ x (* x 10)))
   x)

  

(define x 2)

(let ((x 3)
      (y (+ x 2)))
  (* x y))

  

let赋值域变量不能从另一个获得

posted @ 2017-11-25 02:21  R4mble  阅读(145)  评论(0编辑  收藏  举报