You are encouraged to do this assignment in a two-student team, following the principles of Pair Programming. This does not mean "you do these problems and I'll do those"; it means both students work together, looking over one another's shoulders, to complete all the problems. Turn in one copy with both names on it. I recommend that you choose a different partner for the next homework assignment, so if you don't get along with this partner, remember it's only for a week :-)
Again, please make an appointment for a meeting in my office. This time the purpose of the meeting isn't “get to know you” but rather “demonstrate that you can define a function”. It will be a simple example, but I want to see, with my own eyes, that every student in the class has had the experience of defining a working function, following the design recipe, before we go on to chapter 6.
You are to write six complete function definitions, and parts of two others. (That's one every two days. The first few you do will probably take a while, but once you get used to defining functions, they should take only a few minutes each.) Follow the design recipe!
four-square
function.checkerboard2
function:
the contract is provided in worked exercise 5.3.4, so you should do
examples (5.4.3), skeleton (5.8.3), inventory (5.9.4), body (5.11.3),
and testing (5.12.1).copies-beside
function (exercises 5.3.2, 5.4.2, 5.8.1,
5.9.2). Writing the body requires techniques you don't know yet.bullseye
function:
contract (exercise 5.3.5), examples (5.4.5), skeleton (5.8.4), inventory
(5.9.5), body (5.11.4), and testing (5.12.1).dot-grid
function (exercises
5.3.6, 5.4.6, 5.8.5, 5.9.6). Again, writing the body requires
techniques you don't know yet.lollipop
function:
contract (5.3.7), examples (5.4.7), skeleton (5.8.6), inventory (5.9.7),
body (5.11.5), and testing (5.12.1).checkerboard4
function that
takes in two color names (like checkerboard2
) and produces a
4x4 checkerboard in those colors. Follow all the steps
of the design recipe, in order.
Hint: this will be short and simple if you re-use
previously-defined functions!For exercises 4.3.whatever, I suggest printing out the definitions on paper, then circling and labeling parts of them with pencil or pen. You can also do it on the computer if you prefer.
For the programming problems, 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.
It's difficult for me to grade your testing of these functions, but be assured that I will test them, and if they don't work, it'll hurt your grade, so it's to your advantage to test them before turning them in.
Send me an e-mail, attaching the file containing your saved Definitions pane. (Make sure to save it, then test it, then e-mail it to me, or I may end up grading an out-of-date version.) Make sure to put your name in the Subject line!
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. You may do this using the PSP forms, or simply by keeping track in a text file or on paper and turning it in.
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.
In order to get you feedback quickly, I won't actually grade all of these problems; the rest should be considered practice.
Error log: 25 points
(I'm not grading on how many or how few errors you encountered,
only on whether you recorded them correctly.)
Box-diagram exercises: 10 points each Argument/parameter exercises: 10 points each
Programming exercises:The table below has columns for each step in the design recipe, and a row for each function that I decide to grade. 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 contract, skeleton, and/or inventory.
Function | Contract | Examples | Skeleton | Inventory | Body |
---|---|---|---|---|---|
whatever |
/5 | /5 | /5 | /5 | /15 |
Following directions | /10 |
Writing contracts from word problems | /10 |
Choosing examples | /10 |
Choosing names, indentation, white space... | /10 |
Coding | /10 |
Code re-use and function composition | /10 |