| | Generated: June 17, 2002, 14:41:45 |
The program prog2
Kurt Normark © Aalborg University
Source file: c:/users/kurt/scheme/examples/tutorial/schemedoc/prog2.scm
LAML Version 17.20 (June 1, 2002) development
| This is the demo program prog2 |
|
Table of Contents:
Alphabetic index:
| compose | (compose f g) | A higher order function that composes two functions. | fac | (fac n) | Calculate the factorial of n. | fib | (fib n) | Calculated the fib function. | first | (first lst) | Return the first element of a list | negate | (negate p) | A higher order functions which negates the predicate p. | second | (second lst) | Return the second element of a list |
|
1. THE FAC AND FIB FUNCTIONS.
fac
| Description | | Calculate the factorial of n. |
|
| Preconditions | | The integer must be non-negative. |
|
fib
| Description | | Calculated the fib function.
Notice that this is a very inefficient
implementation. |
|
| Preconditions | | The integer must be non-negative. |
|
| Returns | | The n't fiabonaci number. |
|
2. A COUPLE OF HIGHER ORDER FUNCTION.
These functions are useful in many situations.
negate
| Description | | A higher order functions which negates the predicate p.
Negate accepts a predicate and returns the negated predicate. |
|
| Parameters | | p | | a predicate - p: type -> boolean for any type. |
|
| Returns | | A predicate that returns the negated value. Thus (not ((negate p) x)) = (p x) for all x. |
|
compose
| Description | | A higher order function that composes two functions.
Returns a function which applies f on g.
Both f and g are supposed to take a single argument. |
|
| Parameters | | f | | A function of a single parameter. | g | | A function of a singe parameter. |
|
3. LIST SELECTOR FUNCTIONS.
The functions in this category are alternatives for car, cadr, etc.
first
| Description | | Return the first element of a list |
|
| Returns | | the first element of the list |
|
second
| Description | | Return the second element of a list |
|
| Returns | | the second element of the list |
|
Generated: June 17, 2002, 14:41:45
This documentation has been extracted automatically from the Scheme
source file by means of the Schemedoc tool