On this page:
1 Big Bang
2 Structures
3 Book exercises
6.10.1

Assignment 4: Structures and Enumerations

This assignment is due on Wednesday, 9/13 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 draw function 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. We will ignore variations on streets, such as the difference between "North College" and "South College".

Exercise 6: Write the template for a function which processes an address.

Exercise 7: Design a function 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 which, given two addresses, produces the address with the smaller street number.

Exercise 9: Design a function 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.