Class is finishing in few weeks! Time files!
Last Friday, I got my quiz 6 back and write quiz 7,
Gladly, I get 6 out of of 6 for quiz 6.
For quiz 7, I was unsure about that. Quiz 7 is about recursion.
The code looks like that:
; f: number -> image
(define (f d)
(cond [(zero? d) (circle 10 "outline" "blue")]
[else (above (beside (f (- d 1)) (f (-d 1)))
(circle ( * 10 (+ d 1)) "outline" "blue"))]))
This is not so hard. If we get (f 0), then we have to replace d by 0, and if it is zero, we should get a circle that is "outline" and "blue" sizes 10.
If we get (f 1), we have to replace d by 1, and the (f (-d 1)) is exactly the image we get for (f 0). There are two (f 0) images beside each other, and those two images should on the top of a circle that is outline, blue and sizes 20 which is (1+1) *10.
For (f 2) and (f 3), we should think the same way.
I checked in Drracket, it looks like that:
No comments:
Post a Comment