;The template for a function that takes aData definition:; Apointis either ; a number, indicating a position on the number line, or ; aposn, indicating a position on the x-y plane. ; Aposnis an ordered pair of numbers (x,y) (define-struct posn (x y)) ; make-posn: number number => posn ; posn-x: posn => number ; posn-y: posn => number ; posn?: object => boolean

(define (function-for-point the-point) (cond [(number? the-point) ...] [(posn? the-point) ...]))Furthermore, if (as in this example) some of the possible types are themselves complex, the template for those cases can be elaborated according to the compound data type rule:

(define (function-for-point the-point) (cond [(number? the-point) ...] [(posn? the-point) ... (posn-x the-point) ... ... (posn-y the-point) ...]))

Last modified: Fri Mar 14 16:29:23 EST 2003 Stephen Bloch / sbloch@adelphi.edu