Hello everyone,<br><br><br>#|<br> i will be as brief as i can in explainig the problem. this is the original code of exercise-6.6.6 copied as it is from online version & also from the printed book:<br><br>(draw-a-circle
<br> (move-circle 10<br> (move-circle 10<br> (move-circle 10<br> (move-circle 10 ... a circle ...)))))<br><br><br>;; the last line says ... a circle.... without giving any hint what "a circle" is . i think it is a printing mistake and it should be "...a-circle...". even after changing it to "a-circle" the function does not work.
<br><br> (draw-a-circle (move-circle 10 (move-circle 10 (move-circle 10 (move-circle 10 a-circle)))))<br><br>and i got following ouput:<br><br>-------------------------------------------<br>Welcome to DrScheme, version 209.
<br>Language: Beginning Student.<br>Teachpack: /usr/lib/plt/teachpack/htdp/draw.ss.<br>true<br>color-circle-center: expects argument of type <struct:color-circle>; given true<br>> <br>--------------------------------------------------
<br><br>"true" is from the innermost expression as it moves the cicle 1st time but next lies error.<br><br>it does not move the circle 4 times as told in the book. I think i know the reason. from my common sense (move-circle 10 a-circle) produces not the circle but "true" & hence "true" goes intop drscheme not the circle itself . I have verified this thing from "stepper" too. since (move-circle..) did not get its 2nd parameter as structue it reports an error for it got "true" - the boolean.
<br><br>i am using DrScheme version 209 on Debian "sarge".i got 209 version with the debian's 14 CD packs, but i also tried "plt-209-bin-i386-linux.sh" onto Fedora Core but again the same problem.<br><br>
I have studied only upto chapter 6 of HTDP and i do not know any other language, so please<br>keep the answer according to the HTDP's way.<br><br> may you help me? <br><br>thanks in advance<br>|#<br><br>------------------- here is the programme -----------------------------------
<br><br>(define-struct color-circle (center radius color))<br>;; A color-cirlce is a structure: (make-color-circle cen r col)<br>;; where cen is a posn structure, r is a number and col is a symbol.<br><br>;; in-circle? : a-color-circle, a-posn -> boolean
<br>;; to deiermine whether the point lies inside the circle or not.<br><br>#| Template:<br>(define (fun-for-circle a-circle a-posn)<br> ...(color-circle-center a-circle)...<br> ...(color-circle-radius a-circle)...<br> ...(color-circle-color a-circle)...) |#
<br><br>(define (move-circle delta a-circle)<br> (cond<br> [(draw-and-clear-circle a-circle) (translate-circle a-circle delta)]<br> [else a-circle]))<br><br><br>(define (translate-circle a-color-circle delta)<br> (draw-circle (make-posn (+ delta (posn-x (color-circle-center a-color-circle)))
<br> (posn-y (color-circle-center a-color-circle)))<br> (color-circle-radius a-color-circle)<br> (color-circle-color a-color-circle)))<br><br><br>(define (draw-and-clear-circle a-circle)
<br> (and (draw-a-circle a-circle)<br> (sleep-for-a-while 1)<br> (clear-a-circle a-circle)))<br><br>(define (draw-a-circle a-circle)<br> (draw-circle (color-circle-center a-circle)<br> (color-circle-radius a-circle)
<br> (color-circle-color a-circle)))<br><br>(define (clear-a-circle a-circle)<br> (clear-circle (color-circle-center a-circle)<br> (color-circle-radius a-circle)<br> (color-circle-color a-circle)))
<br><br><br>;; test<br>(define a-circle (make-color-circle (make-posn 30 30) 10 'red))<br><br>(start 300 300)<br>(draw-a-circle (move-circle 10 (move-circle 10 (move-circle 10 a-circle))))<br><br>--------------------- end of programme -------------------------------------
<br>