Compound terms

A compound term is a structure that takes the form $f(t_1,\ldots,t_n)$, where n is called the arity, f is called the functor, or function symbol, and $t_1, \ldots, t_n$ are terms. In B-Prolog, the arity must be greater than 0 and less than 32768. The terms enclosed in the parentheses are called components of the compound term.

Lists are special structures whose functors are '.'. The special atom '[]' denotes an empty list. The list [H|T] denotes the structure '.'(H,T).

By default, a string is represented as a list of codes for the characters in the string. For example, the string "abc" is the same as the list [97,98,99]. The backslash character '\' is used as the escape character for strings. This means that the string "a\"c" is the same as [97,34,98], where 34 is the code for the double quotation mark. The representation of a string is dependent on the flag double_quotes (see Section 6.8).

Arrays and hashtables are also represented as structures. All of the built-ins for structures can also be applied to arrays and hashtables. However, it is suggested that only primitives on arrays and hashtables should be used to manipulate arrays and hashtables.

Neng-Fa Zhou 2013-01-25