Let 和 Let* 的方案混淆 [英] Scheme Confusing of Let and Let*
本文介绍了Let 和 Let* 的方案混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
(let ((x 2) (y 3)
(let ((x 7)
(z (+ x y)))
(* z x)))
有了上面的代码,为什么答案是 35,而不是 70?在第二个 let
中,x 是 7,所以 z 应该是 7 + 3 = 10,然后结果应该是 7 * 10 = 70.我知道还有另一个是 let* 我在这之间很困惑2. 样本来自谷歌.我已经谷歌但就是无法得到它.
With the code above, why is the answer 35, not 70? In the second let
, x is 7 so z should be 7 + 3 = 10, and then the result should be 7 * 10 = 70. I know got another is let* I am very confusing between this 2. The sample is grabs from google. I already google but just can't get it.
推荐答案
x
在调用 (+ xy)
时仍然绑定到外部的 let
代码>.
x
is still bound to the outer let
when calling (+ x y)
.
这篇关于Let 和 Let* 的方案混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文