[plt-scheme] Help with HTDP chapter Generative Recursion

From: Todd O'Bryan (toddobryan at mac.com)
Date: Fri Feb 2 18:12:36 EST 2007

Before you can draw anything on the canvas you need to create a canvas.
Put 

(start HEIGHT WIDTH)

somewhere above the actual draw command.

Todd

On Fri, 2007-02-02 at 21:04 -0200, Henry Lenzi wrote:
> Hi *
> 
>  While reading
> http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-32.html
> 
> I tried out the followind code snippet:
> 
> (define-struct ball (x y delta-x delta-y))
> ;; A ball is a structure:
> ;;   (make-ball number number number number)
> 
> ;; draw-and-clear : a-ball -> true
> ;; draw, sleep, clear a disk from the canvas
> ;; structural desiignn, Scheme knowledge
> (define (draw-and-clear a-ball)
>   (and
>    (draw-solid-disk (make-posn (ball-x a-ball) (ball-y a-ball)) 5 'red)
>    (sleep-for-a-while DELAY)
>    (clear-solid-disk (make-posn (ball-x a-ball) (ball-y a-ball)) 5 'red)))
> 
> (define (move-ball a-ball)
>   (make-ball (+ (ball-x a-ball) (ball-delta-x a-ball))
>              (+ (ball-y a-ball) (ball-delta-y a-ball))
>              (ball-delta-x a-ball)
>              (ball-delta-y a-ball)))
> 
> (define WIDTH 100)
> (define HEIGHT 100)
> (define DELAY .1)
> 
> (define the-ball (make-ball 10 20 -5 +17))
> 
> (and
>  (draw-and-clear the-ball)
>   (draw-and-clear (move-ball the-ball)))
> 
>  Setting the langue to HTDP and requiring draw.ss still does not
> result in the expected action. This is the error:
> 
>  evaluate (start <num> <num>) first
> 
> 
> I also included a sccreenshot with PLT error arrows.
> 
> Anhy help is greatly appreciated.
> TIA.
> 
> Henry
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.