Next: write_out/1 Up: A sketch of Previous: A sketch of

read_in/1

This converts characters read in from the keyboard to a list of Prolog atoms. To illustrate, the input string ``i hope you are well.'' turns into the Prolog term [i,hope,you,are,well,.]. Note the ``.'' as an atom and the avoidance of upper case letters in the input string. A sentence can end with any of {`.',`!',`?'}.

The read_in/1 predicate is structured as follows:

The code for sentence/2 would need to be written. To do this, the built-in predicate is name/2 which turns input ASCII characters into atoms. This is written in such a way that the input is terminated once the user presses Return having written a string of characters that form at least one legal word. Of course, we have to define what a legal word is. At the very least, this includes any sequence of lower case alphabetic characters terminated by a space.


paul@dream.dai.ed.ac.uk
Tue Jan 9 10:51:07 GMT 1996