<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.&nbsp;</div><div><br></div><div>For the advantages of nested defines, see the draft of the Style Guide:&nbsp;</div><div>&nbsp;<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>&gt; From:<span class="Apple-converted-space">&nbsp;</span><a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a><br>&gt; Date: Sun, 11 Mar 2012 19:14:38 -0400<br>&gt; To:<span class="Apple-converted-space">&nbsp;</span><a href="mailto:jgilray@gmail.com">jgilray@gmail.com</a><br>&gt; CC:<span class="Apple-converted-space">&nbsp;</span><a href="mailto:users@racket-lang.org">users@racket-lang.org</a>;<span class="Apple-converted-space">&nbsp;</span><a href="mailto:justin@zamora.com">justin@zamora.com</a><br>&gt; Subject: Re: [racket] spirit of Racket?<br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; I believe the code below cuts your running time to one third. -- Matthias<br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; #lang racket<br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; (require srfi/13)<br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; (define (euler4e)<br>&gt; (for*/fold ([greatest 0]) ([first (in-range 101 1000)] [second (in-range first 1000)])<br>&gt; (define prod (* first second))<br>&gt; (if (palindromic? prod) (max greatest prod) greatest)))<br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; (define (palindromic? n)<br>&gt; (define s (number-&gt;string n))<br>&gt; (define r (string-reverse s))<br>&gt; (string=? s r))<br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt;<span class="Apple-converted-space">&nbsp;</span><br>&gt; ____________________<br>&gt; Racket Users list:<br>&gt;<span class="Apple-converted-space">&nbsp;</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>