2013-10-07 63 views
0
;; makeRectangle -- constructor for 'rectangle 

(define makeRectangle 
    (lambda (x0 y0 x1 y1) 
     (makeGraph 'rectangle 
       (list (makePoint x0 y0) 
        (makePoint x1 y1))))) 

(makeRectangle 3 2 1 7)必須返回(rectangle (point 1 7) (point 3 2)) ,我會得到(makeRectangle 1 2 3 7)(makeRectangle 1 7 3 2)相同的回報,我必須使用:最小值最大值計劃coord.x0 Y0 X1 Y1

min x0 x1 min y0 y1 
max x0 x1 max y0 y1 

但我不知道怎麼做。你能幫我解決這個問題嗎?提前致謝。

回答

1

你的意思是這樣的:

(define makeRectangle 
    (lambda (x0 y0 x1 y1) 
    (makeGraph 'rectangle 
       (makePoint (min x0 x1) (max y0 y1)) 
       (makePoint (max x0 x1) (min y0 y1))))) 

-> (makeRectangle 3 2 1 7) 
'(rectangle (point 1 7) (point 3 2)) 

-> (makeRectangle 1 2 3 7) 
'(rectangle (point 1 7) (point 3 2)) 

-> (makeRectangle 1 7 3 2) 
'(rectangle (point 1 7) (point 3 2)) 

-> (makeRectangle 3 7 1 2) 
'(rectangle (point 1 7) (point 3 2))