Lecture 11: More points
This assignment is due on Sunday, September 29 at 11:59pm. Submit it using Handin as assignment lecture11.
Remember to follow the design recipe whenever you design or write a function. In particular, every type mentioned in a signature must be introduced by a data definition, except for these well-known types: Number, Image, String, Color, Boolean, KeyEvent, MouseEvent, Posn, Anything.
1 Your mission
Have you finished Lecture 10: Unions of structures first? You should.
;; A EvenMorePoints is one of: ;; - (make-none) ;; - (make-one Point) ;; - (make-two Point Point) ;; - (make-three Point Point Point) (define-struct none ()) (define-struct one (first)) (define-struct two (first second)) (define-struct three (first second third)) ;; A Point is (make-point Number Number) (define-struct point [x y])
Exercise 1. Write the template for processing a EvenMorePoints. Make it look like a function called process-evenmorepoints, and do not put it in a comment.
2 The wishlist method
3 Limited
;; A World is a EvenMorePoints
The code written in the videos above is available for your reference. To download it, don’t use “Save Page As” or “Save As”; use “Save Link As” or “Download Linked File” in your Web browser. If you can’t find the command, try right-clicking or two-finger-tapping or long-pressing.