[plt-scheme] Scheme exercise(image.ss)

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Thu Feb 26 16:58:52 EST 2009

On Feb 26, 2009, at 2:13 PM, aditya shukla wrote:

> b) Using the image.ss teachpack in DrScheme, we can write functions  
> that process graphic images. Here is some sample code:
> ;; Traffic Light example, HtDP Section 6.2, Figure 8
> ;; Revised to use image.ss teachpack by Matthias Felleisen
> ...
> This is what i came up with
> ;A traffic light is an image which has a light frame , red , yellow  
> and green lights.
> ;contract traffic-light -> traffic-light(red light turned off)
> ;purpose this function takes a traffic light as input and returns a  
> new-traffic light with red-light turned off.
> (define turn-off-red (lambda(traffic-light)
>                        (overlay/xy (overlay/xy (overlay/xy LIGHT- 
>                           0 0 YELLOW)
>               0 (- OFFSET) (circle RADIUS 'outline 'white) )))
> (turn-off-red ALL-THREE-ON)

First problem: you have only one test case, and even that one doesn't  
specify what the right answer should be.  Almost ANY function should  
have more than one test case.

Second problem: your function never actually uses its parameter,  
which means it'll always produce the same answer regardless of input.

Other than that, it looks reasonable to me.

Stephen Bloch
sbloch at adelphi.edu

Posted on the users mailing list.