HomeContents: |
## 8.4 Atomic constants## IntroductionAtomic constants is another kind of term. We have already come across atomic constants, because atomic constants are nothing more than structures with an arity of 0. Thus atomic constants are just functors with no arguments in parentheses. Atomic constants are also called atoms. ## A functor is an identifierRemember that a functor must be an identifier. An identifier is a sequence of letters, digits, and underscores (_), where the first two characters are letters. ## ExamplesFor example, the following are all atomic constants: - Albert
- March
- Monday
- Aalborg
## What is often the reality behind atomic constants?Good candidates for atomic constants are single entities with a name. For example, Albert Einstein is a single entity with a name. Therefore, his name is a good candidate for being an atomic constant. ## No spaces in atomsNotice that an identifier (and therefore, an atomic constant), cannot contain spaces. Hence, the following are not atomic constants: - Albert Einstein
- Niels Bohr
We could instead write these as: - AlbertEinstein
- NielsBohr
Contracting names with spaces into names without the spaces is common practice in programming. Another common practice is to place underscores in between the words: - Albert_Einstein
- Niels_Bohr
Which we choose doesn't matter, since the identifiers are nothing more than meaningless strings to the computer. ## SummaryAn atomic constant (or simply, an atom) is a structure with arity 0. So it is just a functor. A functor is an identifier. The reality we wish to describe with atoms is often single entities with a name. Atoms cannot contain spaces, because identifiers cannot contain spaces. The two common solutions to this problem is either to contract the words or to place underscores in between the words. ## NextAs we know, there are six kinds of terms. So far, we have treated structures, string constants, and atomic constants. If you want to revise what the others are, you can go back to this page. Next, we treat numeric constants. PrevLite: 8.3 String constantsNextLite: 8.6 Quiz: TermsPrev: 8.3 String constantsUp: 8 TermsNext: 8.5 Numeric constants (Ad) |