8.14
Lecture 13: More self-reference
This assignment is due on Sunday, October 6 at 11:59pm. Submit it using Handin as assignment lecture13.
; A Doll is one of: ; - (make-small-doll String) ; - (make-larger-doll Doll) (define-struct small-doll (color)) (define-struct larger-doll (smaller))
Exercise 1.
Design the function green-doll which takes a
Doll and returns a similar Doll, but the small
Doll at the center has the color "green".
Here’s an example:
(check-expect (green-doll (make-larger-doll (make-small-doll "red"))) (make-larger-doll (make-small-doll "green")))
Exercise 2. Let’s make some pictures like Francis Picabia’s painting Optophone I, to the right.
First, define a constant figure to be a small image. You can make it yourself or copy it from the Internet.
Then, finish designing this function:
; A NaturalNumber is one of: ; - 0 ; - (add1 NaturalNumber)
; optophone : NaturalNumber -> Image ; put figure in front of the given number of concentric rings ; (define (optophone n) ...) (check-expect (optophone 0) figure) (check-expect (optophone 3) (overlay figure (circle 10 "solid" "white") (circle 20 "solid" "black") (circle 30 "solid" "white") (circle 40 "solid" "black") (circle 50 "solid" "white") (circle 60 "solid" "black")))
Feel free to post your (optophone 10) to Discord!