Function definition skeleton

A function definition tells Scheme the name of a new function and how it works. The skeleton of a function definition is a first draft, essentially translating the contract into Scheme syntax but not specifying how the function does its job. It has the following form:
(define (function-name parameter-name)
   ... parameter-name ... )
You can also write functions with multiple parameters:
(define (function-name parameter-name other-parameter-name)
   ... parameter-name ... other-parameter-name ... )
In either case, the definition consists of several parts, each separated by a space (and anywhere you can put a space, you can also put a new line): The first four of these are collectively called the header, and traditionally go on one line, with the body starting on the next line.


(define (cube number)
   ... number ... )
Note that the function-name and parameter-name can each be whatever you want, as long as each is a sequence of letters (and perhaps some punctuation marks, but no spaces). Typically the function-name is chosen to suggest what the function does, and the parameter-name is chosen to suggest the parameter's type or role.

Last modified: Thu Jun 1 14:37:48 EDT 2000
Stephen Bloch /