[plt-scheme] problem

From: Sky O'Mara (skyo at ccs.neu.edu)
Date: Tue Aug 26 00:03:13 EDT 2008

As far as I know, there shouldn't be a problem with using a structure  
within another structure. In what way is it not working?

Here's an example of using a posn inside another structure:
(define-struct foo (a))
(define my-foo (make-foo (make-posn 1 2)))
(foo-a my-foo) ;; -> (make-posn 1 2)
(posn-x (foo-a my-foo)) ;; -> 1

- Sky O.

On Aug 25, 2008, at 7:33 PM, mike wrote:

> I'm presently working through the exercises and have a question about
> 6.6.1;
> it concerns making a structure definition for circle and i simply did
> by
> (define-struct circface (x y radius color))
> and was able to draw the circle by:
> (define (draw-a-circle a-circface)
>  (draw-circle (make-posn (circface-x a-circface) (circface-y a-
> circface))
>                          (circface-radius a-circface) (circface-color
> a-circface)))
> What i tried to do initially was to define the circle structure by
> imbedding
> a posn structure within the definition but it just did not seem to
> work. So
> my question is: can you imbed a data structure within a new data
> structure
> definition? If so can i have a small hint?
> oh example of circle structure used for drawing was defined by:
> (define example1 (make-circface 100 100 50 'red))
> thanks for any input
> mike
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.