Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read/1 2

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Whenever you are entering text using read/1 how do u tell Prolog that u have finished.

Thank you,
Grainne
 
Amzi! Prolog online help says:
If the end-of-file is reached (or [Ctrl-Z] is read from the terminal) then read behaves as though the atom '!EOF' had been read.

This is a test program.

test :- repeat, read(X), test2(X).
test2(X) :- atom(X), X == '!EOF', write('end of file'), !.
test2(X) :- write('You have just entered '), write(X), nl, fail.

?- test.
hello.
You have just entered hello
world.
You have just entered world
<- pressed [Ctrl-Z] and Enter
end of file
yes
?-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top