;; The first three lines of this file were inserted by DrRacket. They record
metadata
;; about the language level of this file in a form that our tools can easily
process.
#reader(lib "htdp-beginner-reader.ss" "lang")((modname pset-02-solution) (read-
case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-
decimal #t #t none #f () #t)))
;; DO NOT PUT ANYTHING PERSONALLY IDENTIFYING BEYOND YOUR CWL IN THIS FILE.
;; YOUR CWLs WILL BE SUFFICIENT TO IDENTIFY YOU AND, IF YOU HAVE ONE, YOUR
;; PARTNER.
;;
(require spd/tags)
(require 2htdp/image)
(@assignment psets/pset-02);Do not edit or remove this tag
(@problem 1)
;;
;; 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 tags.
;;
(@htdf stack)
(@signature Image Image -> Image)
;; stack images, widest on bottom, first on bottom if same width
(check-expect (stack (rectangle 10 5 "solid" "blue")
(rectangle 20 9 "solid" "red"))
(above (rectangle 10 5 "solid" "blue")
(rectangle 20 9 "solid" "red")))
(check-expect (stack (rectangle 20 5 "solid" "blue")
(rectangle 20 9 "solid" "red"))
(above (rectangle 20 9 "solid" "red")
(rectangle 20 5 "solid" "blue")))
(check-expect (stack (rectangle 20 5 "solid" "blue")
(rectangle 10 9 "solid" "red"))
(above (rectangle 10 9 "solid" "red")
(rectangle 20 5 "solid" "blue")))
;(define (stack i1 i2) i1) ;stub
(@template Image)
(define (stack i1 i2)
(if (>= (image-width i1) (image-width i2))
(above i2 i1)
metadata
;; about the language level of this file in a form that our tools can easily
process.
#reader(lib "htdp-beginner-reader.ss" "lang")((modname pset-02-solution) (read-
case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-
decimal #t #t none #f () #t)))
;; DO NOT PUT ANYTHING PERSONALLY IDENTIFYING BEYOND YOUR CWL IN THIS FILE.
;; YOUR CWLs WILL BE SUFFICIENT TO IDENTIFY YOU AND, IF YOU HAVE ONE, YOUR
;; PARTNER.
;;
(require spd/tags)
(require 2htdp/image)
(@assignment psets/pset-02);Do not edit or remove this tag
(@problem 1)
;;
;; 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 tags.
;;
(@htdf stack)
(@signature Image Image -> Image)
;; stack images, widest on bottom, first on bottom if same width
(check-expect (stack (rectangle 10 5 "solid" "blue")
(rectangle 20 9 "solid" "red"))
(above (rectangle 10 5 "solid" "blue")
(rectangle 20 9 "solid" "red")))
(check-expect (stack (rectangle 20 5 "solid" "blue")
(rectangle 20 9 "solid" "red"))
(above (rectangle 20 9 "solid" "red")
(rectangle 20 5 "solid" "blue")))
(check-expect (stack (rectangle 20 5 "solid" "blue")
(rectangle 10 9 "solid" "red"))
(above (rectangle 10 9 "solid" "red")
(rectangle 20 5 "solid" "blue")))
;(define (stack i1 i2) i1) ;stub
(@template Image)
(define (stack i1 i2)
(if (>= (image-width i1) (image-width i2))
(above i2 i1)