Assignment 6a
Due Date: Monday Tuesday at 9:00pm (Week 6)
Purpose Further practice with lists.
Exercise 1 HtDP Exercise 167
Exercise 2 HtDP Exercise 170
Exercise 3 Work through section 10.3, and do HtDP Exercise 172 (this is a long problem, but useful practice)
Exercise 4 Consider the following data definition:
(define-struct contact [name phone]) ; A Contact is a (make-contact String Number) ; An AddressBook is one of: ; - '() ; - (cons Contact AddressBook) ; INTERPRETATION: A list of contacts, with their names and addresses ; A MaybeNumber is one of ; - #false ; - Number ; INTERPRETATION: Represents maybe having a number Write the function find-contact that accepts a String representing the name of a contact and an AddressBook, and returns a MaybeNumber: either the first Number in the AddressBook for a Contact with that name, or if such a contact does not exist, find-contact should return #false.
Graded Exercises
Exercise 5 Consider the following data defintion:
; A Size is one of: ; - "small" ; - "medium" ; - "large" (define-struct drip-coffee [cream size]) (define-struct latte [size]) (define-struct cortado [size]) ; A Coffee is one of: ; - (make-drip-coffee Boolean Size) ; - (make-latte Size) ; - (make-cortado Size) ; INTERPRETATION: Represents three possible coffee orders. Each order ; has a size; drip coffee might also have cream in it. ; A CoffeeOrder is a List-of-Coffee ; INTERPRETATION: The list of coffee orders at a local coffee shop ; A MaybeCoffee is one of ; - #false ; - Coffee ; INTERPRETATION: Represents maybe having a Coffee Design the function last-latte that accepts a CoffeeOrder and returns a Coffee representing the last latte order (i.e., a (make-latte ...)) in the list. If there are no lattes in the CoffeeOrder, it returns #false.
Hint: follow the design recipe carefully here. Be careful with your signatures and templates, and they will help guide your implementation.
Exercise 6 Design examples for the next Forum assignment in Assignment 7a. NOTE: We are giving you a full week to implement this part of the project; it will be due next Monday instead of this Thursday.