I don't know how to compile my prolog program. I'm using "SWI-Prolog" but I don't know how to compile my prolog program. I just typed it and saved in a directory. How do I do to compile it in the main screen? I tried ? - "['C:/Prolog/myfirstprolog']"
-
-
Answer:
To complement 's answer, if you're using Unix/Linux or the command line, I find it best to open a shell, navigate to where the program is and load it with: [name]. With name being the program. Don't use the '.pl' extension. So if I have a module to do basic statistics in /home/alan/Prolog/http://stats.pl, I open a shell and: cd /home/alan/Prolog swipl ?- [stats]. % load my 'http://stats.pl' program ?- meanNums([2,4,5], Mean). Mean = 3.6666666666666665. The full stop / period after the program name ("[stats].") is essential.
Anonymous at Quora Visit the source
Other answers
Suppose you want to distribute only the binary and not your source code, then what you need is to create a "saved state", and specify a "main predicate" where you program starts from. For example, for your program, if your entry point is the predicate main: swipl --goal=main --stand-alone=true -o starts -c http://starts.pl and main would be: main :- write('List=?'), read(List), meanNums(List, Mean), format('Mean=~w~n', [Mean]).
Edison Mera
If you are on Windows, you should be able to click on your file (if you named it something.pl) to run it, otherwise take a look at the FAQ http://www.swi-prolog.org/FAQ/LoadProgram.html
Alexander Lehmann
Related Q & A:
- How to Login to Stackoverflow in Chrome with a different Google ID than the one I'm using for Chrome?Best solution by Meta Stack Overflow
- How can you erase a link on the tab that I don't want to have anymore?Best solution by Yahoo! Answers
- Feeling sick, but I don't know what it's from?Best solution by Yahoo! Answers
- Is there any way I can get my MSN password back if I don't know the secret question that it asks?Best solution by Yahoo! Answers
- How do I find a certain tv channel if I don't know what number it is?Best solution by timewarnercable.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.