[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:


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

The rewritten code is:


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.