November 6th, 2012, 03:31 PM
DrRacket Help Needed!
So, basically, I am supposed to fix the code that my teacher wrote. I fixed almost all of it except one. I attempted multiple times using different definiation for a function but I keep failing. I think it is pretty simple code but I dont know why I cant fix it.
The code goes like this.
; clarify-image : image -> image
; Make alpha 0 for colors with r+g+b > 650, leave other colors as-is, in im
(check-expect (clarify-image (circle 10 "solid" (make-color 250 250 250 255)))
(circle 10 "solid" (make-color 250 250 250 0)))
(check-expect (clarify-image (circle 10 "solid" (make-color 100 100 100 255)))
(circle 10 "solid" (make-color 100 100 100 255)))
; !!! fix the definition of clarify-image ?????
(define (clarify-image c) c)
I am supposed to fix the definition (the bolded part) so that it suits the two check-expects listed above. I know have to use "cond" command in definition such as...
[(> (+ (color-red c) (color-green c) (color-blue c)) 650) 0]
[else (color-alpha c)])))
but other than that, I pretty much don't know what to do.
I am using Intermediate Student with Lambda as the language.