[racket] Exercise 19 How to design programs, second edition

From: Nedim M (nedimm at outlook.com)
Date: Mon Aug 19 09:52:14 EDT 2013

Hello,

I am having a trouble solving Exercise 19 (How to design programs, second edition):

Define the function image-classify, which consumes an image and produces
"tall" if the image is taller than it is wide, "wide" if it is wider
than it is tall, or "square" if its width and height are the same. See
exercise 10 for ideas.

Here is my code:

(require 2htdp/image)

(define (image-classify userImage)

    (define imageHeight (image-height userImage))
    (define imageWidth (image-width userImage))

    (if (> imageHeight imageWidth)
        "tall"
        (if (= imageHeight imageWidth)
            "square"
        "wide"
        )
    )
)

Here is my code for exercise 10:

(require 2htdp/image)
(define cat <imageOfCat>)

(define catHeight (image-height cat))
(define catWidth (image-width cat))

(if (> catHeight catWidth)
    "tall"

    (if (= catHeight catWidth)
        "square"
    "wide"
    )

)

Language is beginning student.
It looks like that declaring calculated constant inside function doesn't work. Example:
(define (image-classify userImage)
(define imageHeight (image-height userImage))

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130819/791305f8/attachment.html>

Posted on the users mailing list.