Assignment 4: Structures and enumerations
This assignment is due on Wednesday, 1/31 at 11:59 PM. Submit it using the handin server as assignment a4.
Note: remember to follow the design recipe for each function you design in this assignment.
1 Big Bang
Exercise 1: Design a function draw which draws a string. The text function will be useful.
Exercise 2: Using your draw function, create a big-bang animation which draws a longer string every time you press a key on the keyboard, using the string from the key you pressed. Your animation should not change if you do not press a key. Make sure to follow the design recipe for all of the functions you write.
Exercise 3: Change your animation so that the string goes back to the empty string “” every time you press the space bar. The string that big-bang gives you for the space bar is ” “.
2 Structures
Exercise 4: Consider the structure definition
(define-struct date (year month day))
List the 5 functions that come with this structure, and what their signatures are.
Exercise 5: An address has a house number, a street name, and city, and a state. Create a structure and data definition for an address. Call the structure address with fields house-number, street-name, city, and state.
Exercise 6: Write the template for a function which processes an address. Call the function process-address.
Exercise 7: Design a function called even-street-side? which, given an address, determines if it is on the even side of the street. The function even? will be useful.
Exercise 8: Design a function called smaller-street-number which, given two addresses, produces the address with the smaller street number.
Exercise 9: Design a function called format-address which, given an address, produces a string that you might write on a letter to that address. In other words, this function should consume an address data structure, and produce a formatted string. The function number->string will be useful.
3 Book exercises
Complete Exercises 83, 84, and 85 from Part I of the book. This will be similar to Exercises 1–3, but with more control and using what you know about structures.