Can anyone explain the difference simply? I don't think I understand the concept from the textbooks/sites I have consulted.
转载于:https://stackoverflow.com/questions/15003518/confused-by-the-difference-between-let-and-let-in-scheme
Can anyone explain the difference simply? I don't think I understand the concept from the textbooks/sites I have consulted.
转载于:https://stackoverflow.com/questions/15003518/confused-by-the-difference-between-let-and-let-in-scheme
If you use let
, you can't reference bindings previously defined in the same let
expression. For example, this won't work:
(let ((x 10)
(y (+ x 6))) ; error! unbound identifier in module in: x
y)
But if you use let*
, it's possible to refer to previous bindings in the same let*
expression:
(let* ((x 10)
(y (+ x 6))) ; works fine
y)
=> 16
It's all here in the documentation.