|Did you know ...
|Representing text: strings, atoms and code lists
With the introduction of strings as a Prolog data type, there are three main ways to represent text: using strings, using atoms and using lists of character codes. As a fourth way, one may also use lists of chars. This section explains what to choose for what purpose. Both strings and atoms are atomic objects: you can only look inside them using dedicated predicates, while lists of character codes or chars are compound data structures forming an extended structure that must follow a convention.
`hello`) can be used to easily specify
a list of character codes. The
0'c notation can be used to
specify a single character code.
'Boeing 747'), but
also individual words in a natural language processing system. They are
also used where other languages would use enumerated types,
such as the names of days in the week. Unlike enumerated types, Prolog
atoms do not form a fixed set and the same atom can represent different
things in different contexts.