Honors 295 - Fall 2003
Programming 1: Symbols and Structure

Due by email to DD, by noon, Sept 19

Solutions

Description

This assignment has four parts, in increasing difficulty.

Don't try to do it all at once. Have you read The Little Schemer? They're serious about the jelly stains.

When you get stuck, ask for help and take a break.

Your answers aren't due until Friday. So you can even ask questions in class next week!

The file structure.scm, which we went over in class, contains definitions to define and access structures of parts and wholes. It creates two sample structures, basic-doric-form and full-doric-form. You will edit and extend this file and hand in your final result. Here's what to do.

  1. The first part of the homework is to write scheme expressions, in terms of full-doric-form, name-of, parts-of and car and cdr, that pick out things for you:
    1. the list of parts of the entablature (the entablature is the first part of the doric form).
    2. the name of the first part of the column (the column is the second part of the doric form).
    3. the list of parts of the cap (the cap is the first part of the pedestal, the third part of the doric form).
    Save your answers by defining them in a line in your answer scheme file. For example, if we had asked as question 1.0 to give the name of the second part of the doric form, you could answer by
    (define a1.0 (name-of (car (cdr (parts-of full-doric-form)))))

  2. The second part of the homework is to create your own structure of parts and wholes. You should create a structure for something that you're reasonably familiar with. Don't worry about reprsenting the whole thing. You might use a selection of parts of the body, a selection of parts of the Rutgers campus, a selection of parts of a computer or car, whatever. The only requirements are that your whole should have at least ten subparts, and the subparts should have four levels of hierarchy. In other words, the whole should have a part one of whose parts has a part of its own. (For example, the doric form has a part, namely the column, one of whose parts, namely the capital, has a part of its own, namely the abacus. The doric form actually has five levels of hierarchy because the abacus has parts, too.)

    Save your answer this way:
    (define a2 (complex-part ...))

  3. Now you should be familiar with these structures. Start by writing two functions, has-part? and get-part.

  4. (Advanced.) Write two more functions, has-subpart? and get-subpart.


295 Home