Flatterm copy_flatterm(Flatterm f);
I2list flat_multiset_vars(Flatterm f);
BOOL flat_occurs_in(Flatterm t1, Flatterm t2);
BOOL flat_variables_multisubset(Flatterm a, Flatterm b);
int flatterm_count_without_vars(Flatterm f);
BOOL flatterm_ident(Flatterm a, Flatterm b);
int flatterm_symbol_count(Flatterm f);
Term flatterm_to_term(Flatterm f);
void fprint_flatterm_mem(FILE *fp, BOOL heading);This routine prints (to FILE *fp) memory usage statistics for data types associated with the flatterm package. The Boolean argument heading tells whether to print a heading on the table.
Flatterm get_flatterm(void);
void p_flatterm(Flatterm f);
void p_flatterm_mem();This routine prints (to stdout) memory usage statistics for data types associated with the flatterm package.
void print_flatterm(Flatterm f);
Flatterm term_to_flatterm(Term t);
void zap_flatterm(Flatterm f);
typedef struct flatterm * Flatterm; struct flatterm { short private_symbol; /* const/func/pred/var symbol ID */ unsigned char arity; /* number of auguments */ Flatterm prev, next, end; /* The rest of the fields are for index retrieval and demodulation. */ int size; /* symbol count */ struct discrim *alternative; /* subtree to try next */ int varnum_bound_to; /* -1 for not bound */ BOOL reduced_flag; /* fully demodulated */ };
The Term macros VARIABLE(f), CONSTANT(f), COMPLEX(f), SYMNUM(f), VARNUM(f), ARITY(f) are used for Flatterms as well. The Term macro ARG(t,i) is NOT used for Flatterms.
Traversing Flatterms. It can be done recursively or iteratively. When building flatterms, recursive is better, because you have to make a Flatterm point to its end. Iterative: Flatterm fi; for (f = fi; fi != f->end->next; fi = fi->next) ... Recursive: int i; Flatterm fi = f->next; for (i = 0; i < ARITY(f); i++) { ... fi = fi->end->next; }