CSC 160
Homework 2

Assigned 5 Feb, due 14 Feb

Links to textbook chapters

Problems

This looks like a lot of problems, but most of them are really short -- a line or two. For example, exercises 5.3.3, 5.4.3, 5.5.3, 5.6.3, and 5.7.2 together make up a single function definition about ten lines long.

What to turn in and how

For problems 3.7.2 (a box diagram), 4.3.2 (identifying parameters and arguments), and 4.6.3 (another box diagram), I recommend printing out the relevant Scheme code on paper, drawing on the paper, and turning in the paper. (This can be done on the computer, but I think it's more hassle than it's worth.)

For the programming problems (4.2.whatever, all of chapter 5, and checkerboard4), I want to see all the steps of the recipe. I recommend putting all of the programming problems in one big Definitions pane; by the time you're done, the contract, definition (including skeleton, inventory, and body), and examples of each function should be together, looking like Figure 5.2 of the textbook. To test these functions, I recommend using the "Log Definitions and Interactions" command on the "File" menu:

  1. Write the various expressions, function contracts, examples, and function definitions in the Definitions pane.
  2. Click "Run". You should see the results of your examples, along with what they "should be", in the Interactions window.
  3. Choose "Log Definitions and Interactions" from the File menu. It will ask you for a "log directory"; I recommend creating a directory named something like "CSC 160 HW2" and using this.
  4. Choose "Stop Logging" from the File menu.
  5. Just to make sure it worked, choose "Open" from the File menu and look in the directory you chose before. You should see two files: 01-definitions and 01-interactions. The definitions file is probably identical to your definitions window. 01-interactions should be whatever was in the Interactions window before you clicked "Log Definitions and Interactions", i.e. just after you clicked "Run".
    (If you see more than two files, e.g. 02-definitions and 02-interactions, it means you clicked "Run" after you started logging. No harm done; the 01 files represent what things looked like before you started logging, and the 02 files represent what things looked like after you hit "Run". Examine all the files and decide which definition pane and which interactions pane to send me.)
  6. Send me an e-mail, attaching both files 01-definitions and 01-interactions. If you've put all the problems into one Definitions pane, you should only need to send these two files; if you've done each problem in a separate window, you'll need to send a lot of files, with a good chance of one of them getting lost.) Make sure to put your name in the Subject line!

Alternatively, you can click "Run" and then save the Definitions and Interactions windows to two separate files, and send me both of these files.

If there's a particular function that you can't get working, turn in as many steps of the recipe as you've managed to do, commented out (so they don't mess up the other functions).

Also turn in a log of how many errors of different kinds you encountered in the assignment, with brief comments describing each one ("mismatched parentheses" is self-explanatory, but more complex errors might need more description). Note that "errors" means not only error messages from DrScheme, but also wrong answers.

General advice

For all assignments in chapters 5 and later, be sure to follow the design recipe. (It couldn't hurt for the problems in chapter 4 either, but it's not required.)

Be sure to choose meaningful names for functions and parameters, and watch for opportunities to re-use functions you (or the textbook) have already written.

This assignment is to be done in pairs, using the ideas from the "kindergarten" article. Choose a partner ASAP and schedule time to work together on the assignment. When you're finished, turn in one assignment with both names on it. You'll have a different partner for homework 3, so if you don't get along with this partner, remember it's only for a week.

Grading standards

Error log:       /25
(I'm not grading on how many or how few errors you encountered, only on whether you recorded them correctly.)

One of Exercises 3.4.2-3.4.6:    /10
One of Exercises 3.5.1-3.5.4:    /10
Exercise 3.7.2:    /10
One of Exercises 4.2.1,4.2.2,4.2.4:    /20
Exercise 4.3.2:    /10
Exercise 4.6.3:    /10

The table below has columns for each step in the design recipe. You won't turn in a separate skeleton, inventory, and body, but rather write a skeleton and then add inventory and body to turn it into a complete definition. However, if you don't get the definition working, you'll still get partial credit for a correct skeleton.

Function name Contract Examples Skeleton Inventory Body Test results
pinwheel /5 /5 /5 /5 /10 /5
checkerboard2 /5 /5 /5 /10 /5
bullseye /5 /5 /5 /5 /10 /5
lollipop /5 /5 /5 /5 /10 /5
checkerboard4 /5 /5 /5 /5 /10 /5
smart-pinwheel (extra credit) /5 /5 /5 /5 /10 /5

General skills:

Following directions /10
Writing contracts from word problems /10
Choosing examples /10
Choosing names /10
Coding /10
Code re-use and function composition /10

Total:         /325


Last modified:
Stephen Bloch / sbloch@adelphi.edu