<html><head><base href="x-msg://81/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>The improvement is not due to the nested result but the string-based palindromic? function. </div><div><br></div><div>For the advantages of nested defines, see the draft of the Style Guide: </div><div> <a href="http://www.ccs.neu.edu/home/matthias/Style/style/index.html">http://www.ccs.neu.edu/home/matthias/Style/style/index.html</a></div><div><br></div><div>-- Matthias</div><div><br></div><div><br></div><br><div><div>On Mar 18, 2012, at 2:57 AM, Racket Noob 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; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; "><div dir="ltr">Which leads to question: when to use nested define and when to use let?<br><br><div><div id="SkyDrivePlaceholder"></div>> From:<span class="Apple-converted-space"> </span><a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a><br>> Date: Sun, 11 Mar 2012 19:14:38 -0400<br>> To:<span class="Apple-converted-space"> </span><a href="mailto:jgilray@gmail.com">jgilray@gmail.com</a><br>> CC:<span class="Apple-converted-space"> </span><a href="mailto:users@racket-lang.org">users@racket-lang.org</a>;<span class="Apple-converted-space"> </span><a href="mailto:justin@zamora.com">justin@zamora.com</a><br>> Subject: Re: [racket] spirit of Racket?<br>><span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> I believe the code below cuts your running time to one third. -- Matthias<br>><span class="Apple-converted-space"> </span><br>> #lang racket<br>><span class="Apple-converted-space"> </span><br>> (require srfi/13)<br>><span class="Apple-converted-space"> </span><br>> (define (euler4e)<br>> (for*/fold ([greatest 0]) ([first (in-range 101 1000)] [second (in-range first 1000)])<br>> (define prod (* first second))<br>> (if (palindromic? prod) (max greatest prod) greatest)))<br>><span class="Apple-converted-space"> </span><br>> (define (palindromic? n)<br>> (define s (number->string n))<br>> (define r (string-reverse s))<br>> (string=? s r))<br>><span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> ____________________<br>> Racket Users list:<br>><span class="Apple-converted-space"> </span><a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></div></div></div></span></blockquote></div><br></body></html>