Introduction -- library(strings)

Quintus Prolog has two data types that can be used to represent sequences of characters. For each sequence of up to N characters for some implementation-defined limit (N is 65532 in Quintus Prolog) there is exactly one atom with that character sequence as its name. Further, each atom has exactly one name.

Atoms provide a convenient and storage-efficient way of handling modest amounts of character data. Two atoms can be compared for identity very quickly using the built-in predicate ==/2.

The second data type is chars. A convention in Prolog is that a list of values all of which belong to the data type thing is said to be of type things. A further convention is that integers representing character codes (the range is 1..255) are said to be of type char. So a chars value is a (possibly empty) list of character codes. A list can be of any length. Two lists can be compared for identity in time proportional to their length by using the built-in predicate ==/2.

In the text that follows, the term text object can generally be taken to refer to an atom.

This section describes how to use the predicates defined in library(strings). If you plan to do extensive text processing, you should consider using lists of character codes rather than atoms, because you will then be able to use an exceptionally powerful pattern-matching language for recognizing patterns and also for constructing new chars. See ref-gru for more about this facility. It is highly recommended that you use grammar rules freely for list and text processing, and that you always consider whether grammar rules can be used clearly to accomplished a desired text processing effect before using the operations in library(strings).