7.7 Term access and construction

Several functions are available to access and construct terms.

OZ_label

OZ_Term OZ_label(OZ_Term term)

Returns the label of term.

OZ_width

int OZ_width(OZ_Term term)

Returns the width of term.

OZ_tuple

OZ_Term OZ_tuple(OZ_Term labelint width)

Returns a new tuple with label label and width width. Note that the values of all subtrees are still undefined. Hence a call to this function should be immediately followed by calls to OZ_putArg.

OZ_putArg

int OZ_putArg(OZ_Term tuple,int pos,OZ_Term arg)

Destructively sets the subtree of tuple tuple at pos to arg. The tuple arguments are numbered starting from 0. Should be only used for tuples created with OZ_tuple.

OZ_mkTuple

OZ_Term OZ_mkTuple(OZ_Term labelint width, ...)

Returns a new tuple with label label and width width. All subtrees from 1 to width must be given as arguments after width. Example:

OZ_mkTuple(OZ_atom("f"),2,OZ_atom("a"),OZ_int(1))

creates the tuple f(a 1).

OZ_mkTupleC

OZ_Term OZ_mkTupleC(char *labelint width, ...)

Analogously to OZ_mkTuple, but expects the label as a C string.

OZ_getArg

OZ_Term OZ_getArg(OZ_Term tupleint pos)

Returns the subtree of tuple tuple at pos. The tuple arguments are numbered starting from 0.

OZ_nil

OZ_Term OZ_nil()

Returns the atom nil.

OZ_cons

OZ_Term OZ_cons(OZ_Term headOZ_Term tail)

Returns a binary tuple with label '|', where the first field is head, the second is tail.

OZ_head

OZ_Term OZ_head(OZ_Term t)

Returns the first field of t. t must be a tuple with label '|' and width 2.

OZ_tail

OZ_Term OZ_tail(OZ_Term t)

Returns the second field of t. t must be a tuple with label '|' and width 2.

OZ_length

int OZ_length(OZ_Term t)

Compute the length of the Oz list t. This function returns -1, if t is not determined and -2, if t is not a list.

OZ_toList

OZ_Term OZ_toList(int nOZ_Term *t)

Creates an Oz list out of an array t of n values.

OZ_pair

OZ_Term OZ_pair(int n)

Returns a mixfix pair, with n subtrees. The subtrees are not initialized and must be defined with OZ_putArg.

OZ_pair2

OZ_Term OZ_pair2(OZ_Term leftOZ_Term right)

Returns a mixfix pair, where the first field is left and the second is right.

OZ_pairA

OZ_Term OZ_pairA(char *leftOZ_Term right)

Macro for creating a mixfix pair of an atom and a value. It is defined as:

OZ_pair2(OZ_atom(left),right)

OZ_pairAA

OZ_Term OZ_pairAA(char *leftchar *right)

Macro for creating a mixfix pair of two atoms. It is defined as:

OZ_pair2(OZ_atom(left),OZ_atom(right))

OZ_pairAI

OZ_Term OZ_pairAI(char *leftint right)

Macro for creating a mixfix pair of an atom and an integer. It is defined as:

OZ_pair2(OZ_atom(left),OZ_int(right))

OZ_pairAS

OZ_Term OZ_pairAS(char *leftchar *right)

Macro for creating a mixfix pair of an atom and a string. It is defined as:

OZ_pair2(OZ_atom(left),OZ_string(right))

OZ_subtree

OZ_Term OZ_subtree(OZ_Term recordOZ_Term feature)

Returns the subtree of record record at feature.}

OZ_record

OZ_Term OZ_record(OZ_Term labelOZ_Term arity)

Creates a new record with label label and list of features arity. Note that the values of all subtrees are still undefined. Hence a call to this function should be immediately followed by calls to OZ_putSubtree.

OZ_recordInit

OZ_Term OZ_recordInit(OZ_Term lbl,OZ_Term propList)

Creates a new record with label lbl. The property list propList contains all features and their subtree as mixfixed pairs.

OZ_putSubtree

void OZ_putSubtree(OZ_Term recordOZ_Term feature,
    OZ_Term newTerm)

Destructively sets the subtree of record record at feature to newTerm. Should be only used for records created with OZ_record or OZ_recordInit.

OZ_arityList

OZ_Term OZ_arityList(OZ_Term record)

Returns the arity of record record as an Oz list.

OZ_adjoinAt

OZ_Term OZ_adjoinAt      
(OZ_Term rec,OZ_Term fea,OZ_Term val)

Returns a new record by adjoining subtree val at feature fea to record rec.

OZ_newVariable

OZ_Term OZ_newVariable()

Creates a new variable.

OZ_newName

OZ_Term OZ_newName()

Creates a new name.}

OZ_newChunk

OZ_Term OZ_newChunk(OZ_Term record)

Creates a new chunk.

OZ_newCell

OZ_Term OZ_newCell(OZ_Term t)

Creates a new cell with initial content t.

OZ_newPort

OZ_Term OZ_newPort(OZ_Term s)

Creates a new port with stream s.

OZ_send

void OZ_send(OZ_Term pOZ_Term t)

Sends value t to port p.

OZ_onToplevel

int OZ_onToplevel()

Returns nonzero iff called on toplevel, i. e. not within a local space.


Michael Mehl, Tobias Müller, Christian Schulte and Ralf Scheidhauer
Version 1.4.0 (20080702)