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

;; Constants (define COOKIES .) ;; ====================================================================== ;; Data Definitions ;; NaturalComplete 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!