Example of non-logical predicates


next up previous contents
Next: Other built-in predicates
Up: Introduction to Prolog for Mathematicians
Previous: Non-logical predicates

Example of non-logical predicates

happy_birthday :-
    read(Name),
    write('Happy Birthday '),
    write(Name),
    write(' '),
    nl.

Read this as:

To do happy_birthday:
    Read a name from the terminal;
    write 'Happy Birthday ';
    write the name;
    write one space;
    move to a new line.

Prolog always executes the tail of a clause from left to right, as in conventional programming languages.



Jocelyn Ireson-Ireson-Paine
Mon Jul 17 22:27:41 BST 1995