File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
Core-CS/Systematic-Program-Design/Part-01/1b-HtDF/quiz Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 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)))
You can’t perform that action at this time.
0 commit comments