six-copies
variable) surround
function).
Note: This exercise is in chapter 5, before the
Design Recipe had been introduced, so you're not strictly required
to use the recipe. But it's still a good idea!pinwheel
contractbullseye
contractpinwheel
examplescheckerboard2
examplesbullseye
examplespinwheel
skeletoncheckerboard2
skeletonbullseye
skeletonpinwheel
definitioncheckerboard2
definitionpinwheel
and
checkerboard2
testingcheckerboard4
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!Extra credit: The version of pinwheel
that I originally wrote works nicely for square pictures, but not so
well for pictures that are longer than they are high, or vice versa;
see the picture at right.
Develop a function
smart-pinwheel
that fits things together snugly, as in
the picture at right.
Hint: You can do this with
image-beside-align-top
,
image-beside-align-bottom
,
image-above-align-left
, and/or
image-above-align-right
.
Another approach is to look in the "Help Desk"
documentation for "image.ss"; look in particular for the word
"pinhole", which is how the teachpack lines up one picture with
another.
For problems 4.6.2 (a box diagram), 5.2.6 (identifying parameters and arguments), and 5.5.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 bullseye
function, I asked you to write a
contract, examples, and skeleton, but no body (because I haven't yet
told you everything you need to write the body). Write
these exactly as if you were going to write a body and test it,
but realize that it won't pass a syntax check or run. To turn it in,
comment out each line of the skeleton and examples,
and include it in the same Definitions window with the rest (see below).
The same goes for any function that for which you don't finish a working
body; do the contract, examples, and skeleton anyway, comment this stuff
out, and include it in the same Definitions window with the rest.
For the remaining problems, I recommend using the "Log Definitions and Interactions" command on the "File" menu:
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".
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 ones to send me.)
01-definitions
and 01-interactions
. If you've put all the problems into
one Definitions window, 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.
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.
For all assignments in chapters 6 and later, be sure to follow the design recipe. (And it couldn't hurt for problem 5.2.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.
Error log: /25
(I'm not grading on how many or how few errors you encountered,
only on whether you recorded them correctly.)
Exercise 3.1.3: /10
Exercise 4.4.2-4.4.5: /20
Exercise 4.6.2: /10
Exercise 5.2.4: /20
Exercise 5.2.6: /10
Exercise 5.5.3: /10
The table below has columns for each step in the design recipe. You won't turn in a separate skeleton and definition, but rather write a skeleton and then add stuff to turn it into a 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 | Definition | Test results |
---|---|---|---|---|---|
pinwheel |
/5 | /5 | /5 | /10 | /5 |
checkerboard2 |
/5 | /5 | /5 | /10 | /5 |
bullseye |
/5 | /5 | /5 | ||
checkerboard4 |
/5 | /5 | /5 | /10 | /5 |
smart-pinwheel (extra credit) |
/5 | /5 | /5 | /10 | /5 |
Following directions | /10 |
Writing contracts from word problems | /10 |
Choosing examples | /10 |
Choosing names | /10 |
Coding | /10 |
Code re-use and function composition | /10 |