title: How to implement let* in scheme?
body: <p>I am trying to learn scheme and trying to implement interpreter for let* in scheme. Here is the grammar:</p>
  
  <pre><code>&lt;s6&gt; -&gt; &lt;expr&gt;                   
         | &lt;define&gt;
  &lt;expr&gt; -&gt; NUMBER | IDENT | &lt;if&gt; | &lt;let&gt; | &lt;letstar&gt; | &lt;lambda&gt; | &lt;application&gt;
  &lt;define&gt; -&gt; ( define IDENT &lt;expr&gt; )
  &lt;if&gt; -&gt; ( if &lt;expr&gt; &lt;expr&gt; &lt;expr&gt; )
  &lt;let&gt; -&gt; ( let ( &lt;var_binding_list&gt; ) &lt;expr&gt; )
  &lt;letstar&gt; -&gt; ( let* ( &lt;var_binding_list&gt; ) &lt;expr&gt; )
  &lt;lambda&gt; -&gt; ( lambda ( &lt;formal_list&gt; ) &lt;expr&gt; )
  &lt;application&gt; -&gt; ( &lt;operator&gt; &lt;operand_list&gt; )
  &lt;operator&gt; -&gt; &lt;built_in_operator&gt; | &lt;lambda&gt; | IDENT
  &lt;built_in_operator&gt; -&gt; + | * | - | /
  &lt;operand_list&gt; -&gt; &lt;expr&gt; &lt;operand_list&gt; | empty
  &lt;var_binding_list&gt; -&gt; ( IDENT &lt;expr&gt; ) &lt;var_binding_list&gt; | ( IDENT &lt;expr&gt; )
  &lt;formal_list&gt; -&gt; IDENT &lt;formal_list&gt; | IDENT
  </code></pre>
  
  <p>I have learned how to implement let before, here it is: </p>
  
  <pre><code>(define let-stmt? (lambda (e)
  (and (list? e) (equal? (car e) 'let) (= (length e) 3))))
  
  (define get-value (lambda (var env)
  (cond
      ((null? env) (error "s6-interpret: unbound variable --&gt;" var))
      ((equal? (caar env) var) (cdar env))
      (else (get-value var (cdr env))))))
  
  (define s6-interpret (lambda (e env)     //thanks to GoZooner
  (cond
      ((number? e) e)
      ((symbol? e) (get-value e env))
      ((not (list? e)) (error "s6-interpret: cannot evaluate --&gt;" e))
  
      ((let-stmt? e)
          (let ((names (map car  (cadr e)))
                  (inits (map cadr (cadr e))))
  
          (let ((vals (map (lambda (init) (s6-interpret init env)) inits)))
  
          (let ((new-env (append (map cons names vals) env)))
  
          (s6-interpret (caddr e) new-env)))))
  </code></pre>
  
  <p>How can i modify interpreter for let so that i can write an interpreter for let*? Can anyone help?</p>
  
  <p>Thanks</p>