# #include "listterm.h"

This page has information from files listterm.h and listterm.c.

## Contents

- Public Routines
- Public Definitions
- Introduction

## Public Routines in File listterm.c

#### Index

cons_term | listterm_cons | listterm_member | listterm_zap
get_nil_term | listterm_i | listterm_reverse | nil_term
listterm_append | listterm_length | listterm_to_tlist | proper_listterm

#### Details

    BOOL cons_term(Term t);

This function checks if a term is a "cons", that is, arity 2 with the official "cons" symbol.

    Term get_nil_term();

Allocate and return an empty listterm.

    Term listterm_append(Term list, Term element);

This routine appends an element to a listterm. The resulting listterm is returned. Neither the list nor the element is copied. You should not refer to the argument "list" after calling this routine---a good way to call it is like this:

    list = listterm_append(list, element)

If "list" is not a proper_listterm(), the result will be well-formed, but it might not be what you expect.

    Term listterm_cons(Term t1, Term t2);

This routine returns the "cons" of two terms. The two terms are not copied.

    Term listterm_i(Term lst, int i);

Return the i-th member, counting from 1, of a listterm. If there are less than i members, return NULL.

    int listterm_length(Term t);

This function returns the length of a listterm.

    BOOL listterm_member(Term t, Term lst);

This function checks if Term t is a member of a listterm (Term lst).

    Term listterm_reverse(Term t);

Reverse a listterm. A new list structure is created, but the members are not copied. The old list structure is freed.

    Plist listterm_to_tlist(Term t);

Given a proper listterm (e.g, [a,b,c]), return a Plist of the members. The members are not copied.

    void listterm_zap(Term t);

Free a list structure, but do not free its members.

    BOOL nil_term(Term t);

This function checks if a term is a "nil", that is, arity 0 with the official "nil" symbol.

    BOOL proper_listterm(Term t);

This function checks if a term is a proper listterm, that is, a nil_term(), or a cons_term() whose tail is a proper_listterm().

## Public Definitions in File listterm.h

## Introduction

This package has routines for managing binary-tree lists built from Terms, which allows you to do some LISPy and Prology things. However, you must be careful to keep track of any terms that are shared and to recycle your own garbage.