How to close an input stream in SWI-Prolog using <CTRL>+<D> combination ?
bot:-
repeat,
write('>'),
readln(X), nl,
answer(X, Answer),
write(Answer), nl,
end(X).
end(X):-member('end',X).
Where X is a list of keywords to that bot
How should I modify source code to get that result?
I have already found a solution.
To get that result I have to apply at_end_of_stream and cut “!“.
Last two lines of code makes it works as I expect.
Now when using combination
Ctrl+Dwe can stop it (close stream which is the same what turning bot off).@larsmans: Nice to know that
readlnis bad or just not optimal. Maybe next time I will use that tip. 🙂