1
stav> swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.0.3)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?-

The only way I found is to run cntr+c multiple times + exit + enter.

is there a simple way to exit?

false
  • 10,264
  • 13
  • 101
  • 209
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
  • Of interest: SWI-Prolog [Overview](https://www.swi-prolog.org/pldoc/man?section=overview) - This starts at the very basics, including halt. – Guy Coder Mar 06 '20 at 13:17
  • Interestingly, `swipl` doesn't "suspend process" when CTRL-Z is entered. Survivable in the age of windowing systems, but not nice. – David Tonhofer Mar 07 '20 at 17:36

1 Answers1

1

Ctrl+D or halt..

Interactive programs that read user input typically exit when you indicate that no more input is coming. Ctrl+D instructs the shell to tell the program that the EOF (end of file) has been reached, causing the program to exit.

This works with virtually all REPLs (Python, NodeJS, Ruby, ...) and many other programs. One random example: Run md5sum on the command line and type in some text. When you're done, press Ctrl+D and see the MD5 hash of the text you entered.

There is another Prolog-specific way to exit, which is the halt predicate (https://www.swi-prolog.org/pldoc/man?predicate=halt/0). Takes longer to type, but allows you to exit programmatically.

Lorenz
  • 1,263
  • 9
  • 20