<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 8, 2012, at 10:25 AM, Ashok Bakthavathsalam wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: 'Lucida Grande'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><pre style="white-space: pre-wrap; color: rgb(34, 34, 34); font-family: monospace, 'Courier New'; padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, 171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 111, 171); border-left-color: rgb(47, 111, 171); background-color: rgb(249, 249, 249); line-height: 1.3em; overflow-x: auto; overflow-y: auto; font-size: 13px; ">&nbsp;<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>

      '<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></span></blockquote></div><br><div>1. These nested lambdas are fine.&nbsp;</div><div><br></div><div>2.&nbsp;</div><div><br></div><div>(define (permute l)&nbsp;</div><div>&nbsp; (cond&nbsp;</div><div>&nbsp; &nbsp; [(null? l) '(())]</div><div>&nbsp; &nbsp; [else (define (silly1 p)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(define (silly2 n)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (insert p n (car l)))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(map silly2 (seq 0 (length p)))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (apply append (map silly1 (permute (cdr l))))]))</div><div><br></div><div><br></div><div><br></div></body></html>