Function template for compound input types

Suppose the data definition for the input reveals that one (or more) of the input parameters is of a compound data type, e.g.
    ; Data definition: 
; A student is a symbol (name), an integer (ID), and a number (GPA)
(define-struct student (name ID GPA))
I recommend that after writing a define-struct, you immediately write down the contracts for all the functions that it defines for you, so the above example becomes
    ; Data definition:
    ; A student is a symbol (name), an integer (ID), and a number (GPA)
    (define-struct student (name ID GPA))
    ; make-student: symbol, integer, number => student
    ; student-name: student => symbol
    ; student-ID: student => integer
    ; student-GPA: student => number
    ; student?: object => boolean
  
Now the definition of a function that takes a student parameter consists of calling each of these functions on the student.
  (define (func-for-student the-student)
     ... (student-name the-student) ...
     ... (student-ID the-student) ...
     ... (student-GPA the-student) ...)
  
Note again that these expressions may actually be used in a different order, and some of them may not all appear at all. If a particular field isn't relevant to the function you're writing, you'll cross it out in the process of writing the body.
Last modified: Wed May 30 12:58:26 EDT 2001
Stephen Bloch / sbloch@adelphi.edu