Generated: Saturday, June 9, 2007, 14:39:54 A SchemeDoc Manual

The program prog2

Kurt Nørmark

Source file: /user/normark/scheme/examples/tutorial/schemedoc/prog2.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.

Table of Contents:
1. The fac and fib functions. 2. A couple of higher order function. 3. List selector functions.

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
Form (fac n)
Description Calculate the factorial of n.
Precondition The integer must be non-negative.
Parameters n An integer
Returns n!
See also Scheme source file fac

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.
See also Scheme source file fib


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.
See also Scheme source file negate

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
See also Scheme source file compose


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
See also Scheme source file first

second
Form (second lst)
Description Return the second element of a list
Parameters lst A list
Returns the second element of the list
See also Scheme source file second

Generated: Saturday, June 9, 2007, 14:39:54
Generated by LAML SchemeDoc using LAML Version 32.2 (June 7, 2007, full)