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

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Nov 2 17:17:34 EDT 2012

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121102/9ad931b4/attachment-0001.p7s>

Posted on the users mailing list.