21. Worksheet C
Create a new struct to hold a number and a posn.
You are going to create a new struct np
that remembers both a number and a posn.
-
Data definition: write a human-understandable description for
np
. -
Write the Racket code to define the
np
structure. -
Write two
check-expect
to verify that you get out the same information that you put in to the structure. -
Design and test
np-set-num: np(old) number -> np(new)
that sets the number in a given number-position structure. -
Design and test
np-set-posn: np(old) posn -> np(new)
that makes the posn of thenp
into the given posn. -
Go do Exercise 21.6.3 using the idea from this worksheet.