I was just looking at exercise 2.64 of SICP, one that creates a BST out of an ordered list of elements:<div><br></div><div> <a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-16.html#%_thm_2.64">http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-16.html#%_thm_2.64</a></div>
<div><br></div><div>However, because of all the nested lets, I have to admit that I was having a hard time reading it!</div><div><br></div><div>So I rewrote it with the Racket style guidelines in mind <a href="http://www.ccs.neu.edu/home/matthias/Style/style/Choosing_the_Right_Construct.html#(part._.Definitions)">http://www.ccs.neu.edu/home/matthias/Style/style/Choosing_the_Right_Construct.html#(part._.Definitions)</a><br>
</div><div><br></div><div><br></div><div>The rewritten code is:</div><div><br></div><div> <a href="https://gist.github.com/4004224">https://gist.github.com/4004224</a><br></div><div><br></div><div>with the following changes:</div>
<div><br></div><div> 1. Rewrote the packing/unpacking of 2-tuple lists in partial-tree with multiple values.</div><div><br></div><div> 2. Replaced nested lets with defines.</div><div><br></div><div> 3. Reordered some of the variables definitions to highlight relationships.</div>
<div><br></div><div><br></div><div>I thought the function itself was neat, and just wanted to share.</div>