[racket] An example of let-vs-define: SICP 2.64

From: Grant Rettke (grettke at acm.org)
Date: Fri Nov 2 17:29:09 EDT 2012

Internal define is awesome.


On Fri, Nov 2, 2012 at 4:17 PM, Matthias Felleisen <matthias at ccs.neu.edu>wrote:

>
> I guess we should take this also as a confirmation of the style guide :-)
>
>
> On Nov 2, 2012, at 5:05 PM, Danny Yoo wrote:
>
> > I was just looking at exercise 2.64 of SICP, one that creates a BST out
> of an ordered list of elements:
> >
> >
> http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-16.html#%_thm_2.64
> >
> > However, because of all the nested lets, I have to admit that I was
> having a hard time reading it!
> >
> > So I rewrote it with the Racket style guidelines in mind
> http://www.ccs.neu.edu/home/matthias/Style/style/Choosing_the_Right_Construct.html#(part._.Definitions)
> >
> >
> > The rewritten code is:
> >
> >     https://gist.github.com/4004224
> >
> > with the following changes:
> >
> >   1. Rewrote the packing/unpacking of 2-tuple lists in partial-tree with
> multiple values.
> >
> >   2. Replaced nested lets with defines.
> >
> >   3. Reordered some of the variables definitions to highlight
> relationships.
> >
> >
> > I thought the function itself was neat, and just wanted to share.
> > ____________________
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>


-- 
Grant Rettke | ACM, AMA, COG, IEEE
grettke at acm.org | http://www.wisdomandwonder.com/
Wisdom begins in wonder.
((λ (x) (x x)) (λ (x) (x x)))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121102/e4ccdba1/attachment.html>

Posted on the users mailing list.