Saturday, 2 February 2019

Prolog: Hello World Program


Step 1: Open any text editior and create HelloWorld.pl with below content

HelloWorld.pl
/*Prolog Hello World Program*/
hello :- write('Welcome to prolog programming!!!Have fun!!!').

Step 2: Open the terminal or command prompt. Go to the directory where your prolog file (HelloWorld.pl) file is located.


Step 3: Execute the command ‘swipl’.
C:\Users\Public\prologExamples>swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 7.6.4)
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).

1 ?-


Load the prolog file by executing the statement.

1 ?- ['HelloWorld.pl'].
true.


Execute the statement ‘hello.’ To get the output in console.

2 ?- hello.
Welcome to prolog programming!!!Have fun!!!
true.



Previous                                                 Next                                                 Home

2 comments:

  1. How did you change background into black?

    Cheers

    ReplyDelete
    Replies
    1. https://www.makeuseof.com/tag/change-colors-command-prompt/

      Delete