首页 > 其他 > 详细

1.3.2 let

时间:2017-11-25 10:44:16      阅读:237      评论:0      收藏:0      [点我收藏+]
(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赋值域变量不能从另一个获得

1.3.2 let

原文:http://www.cnblogs.com/R4mble/p/7894002.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!