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

From: Danny Yoo (dyoo at hashcollision.org)
Date: Fri Nov 2 17:05:08 EDT 2012

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121102/c0509331/attachment.html>

Posted on the users mailing list.