home *** CD-ROM | disk | FTP | other *** search
- /*
- The following C functions can be compiled with any compiler
- that meets the following criteria:
-
- 1) you must be able to compile to large memory model;
- 2) the compiler must not place an '_' after the names of public
- identifiers;
- 3) the compiler must be capable of producing object files
- compatible with the DOS linker;
- 4) you can turn off stack checking. For example, if you are using
- Lattice C, use the -v option.
-
- It is important that your compiler NOT reference its own startup code
- in the course of simple function calls.
-
- the two C structures below are equivalent to the following:
-
- domains
- ilist = integer*
- ifunc = f(integer)
-
- A string can be passed bound as char *string; or free as
- char **string;
-
- For more information on parameter passing,
- see page 156 of the reference manual.
- */
-
- struct ilist {
- char functor; /* type of the list */
- int val; /* the actual element */
- struct ilist *next; /* pointer to next node */
- };
-
- struct ifunc {
- char type; /* type of functor */
- int value; /* value of the functor */
- };
-
- clist_0(in, out)
- struct ilist *in;
- struct ifunc **out;
- {
- (*out)->value = in->val; /* this sets out to f(X) */
- (*out)->type = 1; /* set the functor type */
- }
-
- clist_1(out, in)
- struct ilist **out;
- struct ifunc *in;
- {
- int temp = 0;
-
- temp = in->value;
- temp += temp;
- (*out)->val = temp; /* this returns [2*X] as a list */
- (*out)->functor = 1; /* set the list type. If this is not */
- /* done, no meaningful value will be */
- /* returned */
- }