Compound terms

A compound term is a structure that takes the form of $f(t_1,\ldots,t_n)$ where n is called the arity, and f 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 detaul, a string is represented as a list of codes of 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. So, 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 6.8).

Arrays and hashtables are also represented as structures. All built-ins on structures can be also applied to arrays and hashtables. It is suggested, however, that only primitives on arrays and hashtables be used to manipulate them.

Neng-Fa Zhou 2012-01-03