Question: ;; Constants (define COOKIES .) ;; ====================================================================== ;; Data Definitions ;; Natural is one of: ;; - 0 ;; - (add1 Natural) ;; interp. a
;; Constants (define COOKIES .)
;; ====================================================================== ;; Data Definitions
;; Natural is one of: ;; - 0 ;; - (add1 Natural) ;; interp. a natural number (define N0 0) ;0 (define N1 (add1 N0)) ;1 (define N2 (add1 N1)) ;2
#; (define (fn-for-natural n) (cond [(zero? n) (...)] [else (... n ; n is added because it's often useful (fn-for-natural (sub1 n)))]))
;; Template rules used: ;; - one-of: two cases ;; - atomic distinct: 0 ;; - compound: 2 fields ;; - self-reference: (sub1 n) is Natural
;; ========== ;; Functions
;; Natural Image -> Image ;; produce an n-tall, n-wide pyramid of the given image (check-expect (pyramid 0 COOKIES) empty-image) (check-expect (pyramid 1 COOKIES) COOKIES) (check-expect (pyramid 3 COOKIES) (above COOKIES (beside COOKIES COOKIES) (beside COOKIES COOKIES COOKIES)))
(define (pyramid n i) empty-image) ; stub
Complete the design of the function called pyramid, that takes a natural number n and an image, and constructs an n-tall, n-wide pyramid of copies of that image.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
