Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

;; ;; The following function design may have errors in it . Please fix the error ;; or errors that you find. Any changes you

;;
;; The following function design may have errors in it. Please fix the error
;; or errors that you find. Any changes you make should preserve the existing
;; design intent. NOTE THAT when fixing an error in existing code the best
;; practice is to change as little of the code as possible. That is because
;; in most organizations someone will have to review any changes you make,
;; and changing only what you really mean to change will make that person's
;; job easier. Remember always that the goal is to be kind to your fellow
;; programmers.
;;
;; First uncomment the entire function design, and then fix the error.
;; If you are unable to find and fix the error, leave it commented out.
;; Note that when fixing a bug in an existing program your goal should
;; be to have a light touch. If there is a small simple way to fix
;; something then do it the small and simple way.
;;
;; Your solution must include @htdf, @signature, and @template-origin tags.
(@htdf stack)
(@signature Image Image -> Image)
;;stack images, widest on bottom, first on bottom if same width
(check-expect (stack (rectangle 105 "solid" "blue")
(rectangle 209 "solid" "red"));
(above (rectangle 105 "solid" "blue")
(rectangle 209 "solid" "red")))
(check-expect (stack (rectangle 205 "solid" "blue")
(rectangle 209 "solid" "red"))
(above (rectangle 209 "solid" "red")
(rectangle 205 "solid" "blue")))
(check-expect (stack (rectangle 205 "solid" "blue")
(rectangle 109 "solid" "red"))
(above (rectangle 109 "solid" "red")
(rectangle 205 "solid" "red")))
;;(define (stack i1 i2) img-stacked) ;stub
(@template-origin Image);
(@template
(define (stack i1 i2)
(... i1 i2)))
(define (stack i1 i2)
(cond [(>(image-width i1)(image-width i2))
(above i1 i2)]
[(<(image-width i1)(image-width i2))
(above i2 i1)]
[else (above i2 i1)]))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions