;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "2017-fall-reader.rkt" "csc104")((modname Week-7-Lab) (compthink-settings #hash((prefix-types? . #f)))) ; Exercises for Week 7 ; ==================== ; The quiz on October 25th will be related to this exercise. ; You should do very well on the quiz if you try out everything below. ; Instructors/TAs are available before quizzes for questions, 10--3 on Wednesday in BA 3175. ; Quiz Rooms ; ---------- ; TUT0201 11-12 ; 11:30 surnames A--L RS310 ; 11:30 surnames M--V HA316 ; 11:45 surnames W--Z RS310 ; ; TUT0301 12--1 ; 12:30 surnames A--M BF323 ; 12:45 surnames N--Z BF323 ; ; TUT0401 1--2 ; 1:30 surnames A--M UC256 ; 1:45 surnames N--Z UC256 ; ; TUT0501 2--3 ; 2:30 surnames A--M RS310 ; 2:45 surnames N--Z RS310 ; ; TUT0101 3--4 ; 3:30 surnames A--M RW140 ; 3:45 surnames N--Z RW140 ; ★ Draw the result for each of: (a 0) (a 1) (a 2) (a 3). ; Write out any of the intermediate steps that you find helpful. (define (a k) (cond [(= k 0) (star 10 "solid" "gold")] [else (beside (a (- k 1)) (star (* 10 (+ k 1)) "solid" "gold"))])) ; To help you understand the process: #;(step parallel (a 0)) #;(step parallel (hide (a 0)) (a 1)) #;(step parallel (hide (a 1)) (a 2)) #;(step parallel (hide (a 2)) (a 3)) ; ★ Draw the result of (S 10) and (S 20). (define (S side-length) (square side-length "outline" "forestgreen")) ; ★ Draw the result for each of: (b 0) (b 1) (b 2) (b 3). ; Write out any of the intermediate steps that you find helpful. (define (b n) (cond [(positive? n) (above (b (- n 1)) (S (* 2 (image-width (b (- n 1))))))] [else (S 10)])) ; To help you understand the process: #;(step parallel (hide S) (b 0)) #;(step parallel (hide S (b 0)) (b 1)) #;(step parallel (hide S (b 1)) (b 2)) #;(step parallel (hide S (b 2)) (b 3)) ; ★ Draw the result for each of: (c 0) (c 1) (c 2) (c 3). ; Write out any of the intermediate steps that you find helpful. (define (c i) (cond [(zero? i) (S 10)] [else (beside (above (c (- i 1)) (c (- i 1))) (S (* 10 (+ i 1))))])) ; To help you understand the process: #;(step parallel (hide S) (c 0)) #;(step parallel (hide S (c 0)) (c 1)) #;(step parallel (hide S (c 1)) (c 2)) #;(step parallel (hide S (c 2)) (c 3)) ; ★ Draw the result for each of: (d 0) (d 1) (d 2) (d 3). ; Write out any of the intermediate steps that you find helpful. (define (d n) (cond [(>= n 1) (overlay (beside (d (- n 1)) (d (- n 1))) (S (image-width (d (- n 1)))))] [else (S 20)])) ; To help you understand the process: #;(step parallel (hide S) (d 0)) #;(step parallel (hide S (d 0)) (d 1)) #;(step parallel (hide S (d 1)) (d 2)) #;(step parallel (hide S (d 2)) (d 3)) ; ★ Draw the result for each of: (e 0) (e 1) (e 2) (e 3). ; Write out any of the intermediate steps that you find helpful. (define (e n) (cond [(= n 0) (S 20)] [else (overlay (S (* 2 (image-width (e (- n 1))))) (rotate 90 (beside (e (- n 1)) (e (- n 1)))))])) ; To help you understand the process: #;(step parallel (hide S) (e 0)) #;(step parallel (hide S (e 0)) (e 1)) #;(step parallel (hide S (e 1)) (e 2)) #;(step parallel (hide S (e 2)) (e 3))