Below, I have enclosed the code from Rosetta for generating Permutations. Can someone show me how to replace nested lambdas with defines? <div>Thanks,<br><div><br></div><div><pre style="white-space:pre-wrap;color:rgb(34,34,34);font-family:monospace,&#39;Courier New&#39;;padding:1em;border:1px dashed rgb(47,111,171);background-color:rgb(249,249,249);line-height:1.3em;overflow:auto;font-size:13px">
<span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">define</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span>insert <span style="font-weight:bold;color:rgb(0,0,255)">l</span> n <span style="font-weight:bold;color:rgb(0,0,255)">e</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

  <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">if</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span>= <span style="font-weight:bold;color:rgb(0,153,153)">0</span> n<span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

      <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">cons</span> <span style="font-weight:bold;color:rgb(0,0,255)">e</span> <span style="font-weight:bold;color:rgb(0,0,255)">l</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

      <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">cons</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">car</span> <span style="font-weight:bold;color:rgb(0,0,255)">l</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span> <br>

            <span style="font-weight:bold;color:rgb(0,153,0)">(</span>insert <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">cdr</span> <span style="font-weight:bold;color:rgb(0,0,255)">l</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span>- n <span style="font-weight:bold;color:rgb(0,153,153)">1</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span> <span style="font-weight:bold;color:rgb(0,0,255)">e</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

 <br><span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">define</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span>seq start end<span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

  <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">if</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span>= start end<span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

      <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">list</span> end<span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>
      <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">cons</span> start <span style="font-weight:bold;color:rgb(0,153,0)">(</span>seq <span style="font-weight:bold;color:rgb(0,153,0)">(</span>+ start <span style="font-weight:bold;color:rgb(0,153,153)">1</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span> end<span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

 <br><span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">define</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span>permute <span style="font-weight:bold;color:rgb(0,0,255)">l</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

  <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">if</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">null?</span> <span style="font-weight:bold;color:rgb(0,0,255)">l</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

      &#39;<span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

      <span style="font-weight:bold;color:rgb(0,153,0)">(</span>apply <span style="font-weight:bold;color:rgb(0,0,255)">append</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">map</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">lambda</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span>p<span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

                           <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">map</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">lambda</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span>n<span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

                                  <span style="font-weight:bold;color:rgb(0,153,0)">(</span>insert p n <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">car</span> <span style="font-weight:bold;color:rgb(0,0,255)">l</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

                                <span style="font-weight:bold;color:rgb(0,153,0)">(</span>seq <span style="font-weight:bold;color:rgb(0,153,153)">0</span> <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">length</span> p<span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><br>

                         <span style="font-weight:bold;color:rgb(0,153,0)">(</span>permute <span style="font-weight:bold;color:rgb(0,153,0)">(</span><span style="font-weight:bold;color:rgb(0,0,255)">cdr</span> <span style="font-weight:bold;color:rgb(0,0,255)">l</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span><span style="font-weight:bold;color:rgb(0,153,0)">)</span></pre>
</div></div>