Step 3 − Now create one file (extension is *.pl) and write the code as follows − main :- write('This is sample Prolog program'),write(' This program is written into hello_ file'). Now we can see in the prolog console, it shows that we have successfully changed the directory. Step 2 − Select the proper folder and press OK. Step 1 − From the prolog console, go to File > Change Dir, then click on that menu. In both cases, the file is created, if it. read means that the file is opened for reading, and write and append both open the file for writing. Now let us see how to run the Prolog script file (extension is *.pl) into the Prolog console.īefore running *.pl file, we must store the file into the directory where the GNU prolog console is pointing, otherwise just change the directory by the following steps − open (+FileName,+Mode,-Stream) The first argument of open is the name of the file, and in the last argument, Prolog returns the name that it assigns to the stream. One of the most important CLP (FD) constraints denotes arithmetic equality and is called ()/2. For example, in the case of integers, try your Prolog system's CLP (FD) constraints. The corresponding output will be as shown below − Prolog also provides much more general arithmetic predicates in the form of arithmetic constraints. Note − After each line, you have to use one period (.) symbol to show that the line has ended. This predicate takes the parameter as input, and writes the content into the console by default. To do so, we have to write the command as follows − write('Hello World'). To write the output we can use the write() predicate. Hello World ProgramĪfter running the GNU prolog, we can write hello world program directly from the console. Now, we will see how to write a simple Hello World program in our Prolog environment. The definition of prologue introduce important informationsuch as background details, or charactersthat have some connection to the main story, but whose relevance is not immediately obvious. In the previous section, we have seen how to install GNU Prolog. A prologue is a piece of writing found at the beginning of a literary work, before the first chapter and separate from the main story.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |