title: Scheme: mapping let and set! onto lists
body: <p>I am trying to map let and set! onto lists something like this:</p>
  
  <pre><code>(map (lambda (x) (let ((x #f)))) &lt;list&gt;)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>(map set! &lt;list1&gt; &lt;list2&gt;)
  </code></pre>
  
  <p>But, of course, neither is working.</p>
  
  <p>Is there a way to do this?  Any advice is appreciated.</p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p>The real problem is that I am trying to find a way to pattern match letrec.  I need to be able to pattern match:</p>
  
  <pre><code>(letrec ((var val) ...) expr0 expr1 ...)
  </code></pre>
  
  <p>and convert it -- using match-lambda -- to an equivalent call using only let and set!  This is the template I am trying to emulate:</p>
  
  <pre><code>(letrec ((var val) ...) expr0 expr1 ...)
  </code></pre>
  
  <p>==></p>
  
  <pre><code>(let ((var #f) ...)
  (let ((temp val) ...)
  (set! var temp) ...
  (let () expr0 expr1 ...)))
  </code></pre>
  
  <p>The problem is translating this into syntax that match-lambda accepts.  Here is what I was working on, assuming there was a way to accomplish the original question:</p>
  
  <pre><code>(match-rewriter (`(letrec((,&lt;var&gt; ,&lt;val&gt;) ...) ,&lt;expr&gt; ...)
                     `((map (λ (x) (let ((x #f)))) ,&lt;var&gt;)
                        (let ((temp ,&lt;val&gt;)))
                          (map set! ,&lt;var&gt; temp)
                          (let () ,@&lt;expr&gt;))))
  </code></pre>
  
  <p>Any advice is appreciated.</p>
  
  <p>Thanks.</p>