Week 3 Set a
Due Date Mon at 9:00pm (Week 3)
Purpose these exercises prepare you for the exam; we may also grade some of the solutions
Finger Exercises
Exercise 1 Here are the structure-type and data definitions:
(define-struct 3d (x y z)) ; A ThreeD is (make-3d NNN NNN NNN). ; A NNN is a nonnegative real Number. Design a function that consumes a 3d structure and determine whether it is a ThreeD.
Design a function that adds the respective coordinates of two ThreeD points.
Also design a function that subtracts the respective coordinates of two ThreeD points. Note If the coordinate of the second ThreeD is larger than the corresponding coordinate from the first, the result would be negative; since this is not legal according to the data definition, place a 0 in the place of the difference.
Graded Exercises
(define-struct week (mon wed thu)) (define-struct lecture (date topic readings)) (define-struct date (month date)) ; A Week is (make-week HolidayLecture HolidayLecture HolidayLecture) ; A HolidayLecture is one of: ; – String ; – (make-lecture Date String String) ; interpretation a String refers to a holiday, ; a lecture to a date, a topic, and URL for a reading assignment ; A Date is (make-date Number Number)
Exercise 2 Design the function turn-into-holiday. It consumes a Week and one of these Strings: "mon", "wed", "thu". Its result is like the given one, with the indicated day turned into a holiday.
Exercise 3 Design the function flip, which consumes a Week and flips the numbers in all Date structures.
Exercise 4 Design the function prefix. It consumes a Week and a String. The latter is added to the left of each readings String in a lecture structure.