| Generated: Saturday, June 9, 2007, 14:58:22 | | A SchemeDoc Manual |
The program prog3
Kurt Nørmark
Source file: /user/normark/scheme/examples/tutorial/schemedoc/man/../prog3.scm
This is a Scheme file with a few simple functions. The functions are written and organized with the purpose of demonstrating the LAML SchemeDoc tool.
|
1 The fac and fib functions. |
|
|
| fac |
| Form | (fac n) |
| Description | Calculate the factorial of n. |
| Precondition | The integer must be non-negative. |
| Parameters | n | An integer |
| Returns | n! |
|
| fib |
| Form | (fib n) |
| Description | Calculated the fib function. Notice that this is a very inefficient implementation. |
| Precondition | The integer must be non-negative. |
| Parameters | n | An integer |
| Returns | The n't fiabonaci number. |
|
2 A couple of higher order function. |
| These functions are useful in many situations. |
|
| negate |
| Form | (negate p) |
| 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 |
| Form | (compose f g) |
| 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. |
| Returns | f ° g |
|
3 List selector functions. |
| The functions in this category are alternatives for car, cadr, etc. |
|
| first |
| Form | (first lst) |
| Description | Return the first element of a list |
| Parameters | lst | A list |
| Returns | the first element of the list |
|
| second |
| Form | (second lst) |
| Description | Return the second element of a list |
| Parameters | lst | A list |
| Returns | the second element of the list |
|