Examples for data types defined by parts

Suppose you're defining a data type circle with three parts: a center of type posn, a radius of type number, and a color of type symbol (e.g. 'red, 'blue, etc.) Since you've already written function contracts for the functions given by your define-struct, you know that there's a function named make-circle that takes in a posn, a number, and a symbol in that order, and returns a circle. So to create an example of the circle type, simply call this function on arguments of the appropriate types:

(make-circle (make-posn 3 4) 5 'red)
Note that since the first parameter was a posn, we needed to call make-posn to get an example of the posn type which we could then pass into make-circle.


Last modified: Tue Jan 14 15:06:25 EST 2003
Stephen Bloch / sbloch@adelphi.edu