The posn structure is built into DrScheme's teaching
languages, including make-posn, posn-x, and
posn-y.
When you type
(make-posn 1 2)(make-posn 1 2)1 and 2.
In contrast, enter
(make-posn (+ 1 2) 4)(make-posn 3 4)(+ 1 2) can be reduced to the simpler
3. But, as before, there is no simpler name for a posn
containing 3 and 4 other
than (make-posn 3 4).
Wehn you evaluate (start 300 300) with the draw.ss
library, DrScheme create a new, empty drawing canvas, like this one:
Evaluating a drawing expressions, such as
(draw-solid-line (make-posn 100 100) (make-posn 200 200) 'red)
If you try to evaluate drawing expressions before using
start, DrScheme reports an error message that reminds you to
use start.
When the canvas window appears with your images, do not close it,
because there is no way to re-open a closed canvas window. Instead,
you have to re-execute your program, or create a new canvas window
with start.
If you use start multiple times, drawing commands affect the
most recently created canvas.
To close a canvas (when you are done with it), you can click the
canvas window's close box, or evaluate (stop). Clicking
DrScheme's Execute button also closes canvas windows.
Exercise Notes
Exercise 6.2.1 To open Help Desk, select the Help|Help Desk menu item. On Help Desk's home page, the third major bullet has a sub-link Teachpacks that provides a menu of Teachpack documentation links.
The posn structure is built into DrScheme, so you cannot define it
yourself. (If you try, DrScheme will report such as ``cannot redefine
name: make-posn'''.)
Structure definitions with define-struct are analogous to
function definitions, in that the definition can appear either before
or after functions using the structure, but must always precede
examples using the structure.
To include a data definition in your program file, use a comment (just as for contracts):
;; A star is a structure ;; (make-star last first instrucment sales) ;; where last, first, and instrucment are symbols ;; and sales is a number.
No DrScheme notes for this section.
Use the draw.ss teachpack for this exercise. For information about selecting a teachpack, see the Exercise Notes for Exercise 2.2.1.
Initially, use the draw.ss teachpack for this exercise, then switch to hangman.ss as directed. For information about selecting a teachpack, see the Exercise Notes for Exercise 2.2.1.