9 A simple Prolog program
Students and their semesters
We have looked at what a term is. We have seen four of the six kinds of terms. Now we combine this knowledge into a small, complete program. Consider the following Prolog program:
student(Lisa, 5). student(Martin, 3). student(John, 3). student(Edward, 7).
It is available as the file "Students1.plgCG" in the AAU sample directory.
The program consists of four facts, each of which consists of a structure and a period ("."). Each structure denotes a relationship between a student's name and the semester at which the student is studying. Thus Lisa is in the fifth semester, while Martin is in the third, etc.
We will reprint this sample program on subsequent pages when necessary.
PrevLite: 8.6 Quiz: Terms
NextLite: 9.1 Facts and the program database
Prev: 8.6 Quiz: Terms
Up: Part III: Programming
Next: 9.1 Facts and the program database