Function template for compound output types
Suppose the data definition for the output reveals that the output
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
In particular, since your function has to return a student, it's
likely to use the make-student function:
(define (func-returning-student ...)
(make-student symbol integer number))
in which each of the slots symbol, integer, and
number needs to be filled in with something of the appropriate type.
Each of these may be a constant, an
argument from the function header, or a complex expression in its own
right, but it must be of the right type.
Last modified:
Thu Jan 20 10:36:51 EST 2000
Stephen Bloch / sbloch@adelphi.edu