Skip to content

Commit ddd2c57

Browse files
committed
complete quiz 1
1 parent ff9857b commit ddd2c57

File tree

1 file changed

+31
-1
lines changed
  • Core-CS/Systematic-Program-Design/Part-01/1b-HtDF/quiz

1 file changed

+31
-1
lines changed
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
#reader(lib "htdp-beginner-reader.ss" "lang")((modname quiz-1) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
2+
(require 2htdp/image)
13
; PROBLEM:
4+
; Design a function that consumes two images and produces true if the first is larger than the second.
25

3-
; Design a function that consumes two images and produces true if the first is larger than the second.
6+
;Solution
7+
8+
9+
10+
;Image -> Boolean
11+
;Check whether an image is larger than another
12+
13+
(define img1 (square 20 "solid" "yellow"))
14+
(define img2 (square 30 "solid" "yellow"))
15+
(define img3 (square 25 "solid" "yellow"))
16+
(define img4 (square 50 "solid" "yellow"))
17+
18+
(check-expect (is-image-larger img1 img1) (> (image-width img1) (image-width img1)))
19+
(check-expect (is-image-larger img1 img2) (> (image-width img1) (image-width img2)))
20+
(check-expect (is-image-larger img1 img3) (> (image-width img1) (image-width img3)))
21+
(check-expect (is-image-larger img1 img4) (> (image-width img1) (image-width img4)))
22+
(check-expect (is-image-larger img2 img3) (> (image-width img2) (image-width img3)))
23+
(check-expect (is-image-larger img2 img4) (> (image-width img2) (image-width img4)))
24+
(check-expect (is-image-larger img3 img4) (> (image-width img3) (image-width img4)))
25+
26+
;(define (is-image-larger first-image second-image) ;stub
27+
; true)
28+
29+
;(define (is-image-larger image1 image2)
30+
; (... image1 image2))
31+
32+
(define (is-image-larger image1 image2)
33+
(> (image-width image1) (image-width image2)))

0 commit comments

Comments
 (0)