(require spd/tags)
(require 2htdp/image)
(require 2htdp/universe)
(@assignment lab-05)
(@cwl ???)
;; Problem 1
;; Complete the design of a 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.
;; For instance, a 3-wide pyramid of cookies would look like this:
;(bitmap/url
;"https://edx-course-spdx-kiczales.s3.amazonaws.com/HTC/lab/
; cookies-pyramid.png")
;(run in interactions window)
; Constants
(define COOKIES
(bitmap/url
"https://edx-course-spdx-kiczales.s3.amazonaws.com/HTC/lab/cookies.png"))
(define SQUARE (square 10 "solid" "blue"))
, ;; ======================================================================
;; Data Definitions
(@htdd Natural)
;; 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
(@dd-template-rules one-of
atomic-distinct
compound
self-ref)
(define (fn-for-natural n)
(cond [(zero? n) (...)]
[else
(... n ; n is added because it's often useful
(fn-for-natural (sub1 n)))]))
;; ==========
;; Functions