Quirksand

SICP

SICP 2.1.2 Exercises

January 7, 2014 11:23

The exercises continue to be fairly short, with only two this time. These can build on each other, although given that we’re dealing with abstractions, they don’t necessarily have to. The use of the abstractions and the suggested names for the procedures to implement allows for easy testing. As long as you’re using the names, the code for testing is the same regardless of how it is implemented.

It will be necessary to add the lines for the constructors, as the way you initially feed data into the structure is not part of the abstraction. Indeed, it would be possible to create the same structure using a different method of input (something that will be done later on in the book). There are some optional tests that get at what valid input is and how it is used; the results are worth examining but as always there isn’t meant to be an implication that there is just one way it should be handled.

Exercises 2.1.2