[racket] spirit of Racket?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Mar 18 18:30:06 EDT 2012

The improvement is not due to the nested result but the string-based palindromic? function. 

For the advantages of nested defines, see the draft of the Style Guide: 
 http://www.ccs.neu.edu/home/matthias/Style/style/index.html

-- Matthias



On Mar 18, 2012, at 2:57 AM, Racket Noob wrote:

> Which leads to question: when to use nested define and when to use let?
> 
> > From: matthias at ccs.neu.edu
> > Date: Sun, 11 Mar 2012 19:14:38 -0400
> > To: jgilray at gmail.com
> > CC: users at racket-lang.org; justin at zamora.com
> > Subject: Re: [racket] spirit of Racket?
> > 
> > 
> > I believe the code below cuts your running time to one third. -- Matthias
> > 
> > #lang racket
> > 
> > (require srfi/13)
> > 
> > (define (euler4e)
> > (for*/fold ([greatest 0]) ([first (in-range 101 1000)] [second (in-range first 1000)])
> > (define prod (* first second))
> > (if (palindromic? prod) (max greatest prod) greatest)))
> > 
> > (define (palindromic? n)
> > (define s (number->string n))
> > (define r (string-reverse s))
> > (string=? s r))
> > 
> > 
> > ____________________
> > Racket Users list:
> > http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120318/25613704/attachment-0001.html>

Posted on the users mailing list.