Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This <code>let</code> expression:</p> <pre><code>(let ((x v1) (y v2)) e) </code></pre> <p>Is equivalent to the following <code>lambda</code> application, noticing that in here the variables can be evaluated in any order (no strict left-to-right order is enforced) and the definition of one variable can not reference the variables before it:</p> <pre><code>((lambda (x y) e) v1 v2) </code></pre> <p>On the other hand, this <code>let*</code> expression:</p> <pre><code>(let* ((x v1) (y v2) (z v3)) e) </code></pre> <p>Can be transformed into a series of nested <code>lambda</code>s, in a way that ensures that the variables are evaluated in the same order that was used to define them, and the ones defined first can be referenced in all subsequent definitions:</p> <pre><code>((lambda (x) ((lambda (y) ((lambda (z) e) v3)) v2)) v1) </code></pre> <p>Another example: this code will only work if we use the second transformation:</p> <pre><code>(let* ((x 1) (y (+ x 1))) (+ x y)) </code></pre> <p>As you can see, the definition of <code>y</code> references <code>x</code>, only in this way will it work:</p> <pre><code>((lambda (x) ((lambda (y) (+ x y)) (+ x 1))) 1) </code></pre> <p>Finally, here are two great online books for learning Scheme:</p> <ul> <li><a href="http://www.ccs.neu.edu/home/matthias/HtDP2e/" rel="nofollow">How to Design Programs</a></li> <li><a href="http://mitpress.mit.edu/sicp/full-text/book/book.html" rel="nofollow">Structure and Interpretation of Computer Programs</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload