<div>The Guide contains th following example illustrating the use of named let:</div>
<div> </div>
<div>(define (duplicate pos lst) <br> (let dup ([i 0] <br> [lst lst]) <br> (cond <br> [(= i pos) (cons (car lst) lst)] <br> [else (cons (car lst) (dup (+ i 1) (cdr lst)))]))) <br> <br> <br> > (duplicate 1 (list "apple" "cheese burger!" "banana")) <br>
("apple" "cheese burger!" "cheese burger!" "banana")</div>
<div> </div>
<div> </div>
<div>I can see that i is initially bound to 0, but [lst lst] looks odd. The equivalent letrec</div>
<div> </div>
<div> (letrec ([proc-id (lambda (arg-id ...) <br> body ...+)]) <br> (proc-id init-expr ...)) </div>
<div> </div>
<div>helps, because it shows that lst needs to appear (with some binding) to be an argument to th elambda expression bound to dup. At least that's my reading.</div>
<div> </div>
<div>I don't use named let much (which is why I was looking it up), and so this may not be a good example, but since this is The Guide, I wonder if providing an example along the lines of</div>
<div> </div>
<div>(define (factorial n)<br> (let fact ([i 0] [result 1])<br> (if (= i n)<br> result<br> (fact (+ i 1) (* (+ i 1) result)))))</div>
<div> </div>
<div>first might make it seem a bit less mysterious. (Wow, that was all one sentence!)</div>