Prolog is about running a query against a program. The query goes into the bottom-left editor and the program into the left editor. The program can be empty, executing queries against the built-in predicates of Prolog. For example:
?- format("Hello world!~n").
A query can be executed by hitting RETURN
if the query
is complete and the caret is behind the '.' that terminates the query
or by using the Run! button. At this moment, the following happens:
Note that you do not have to save your program to execute it. If your are not satisfied with the answer to a query, you can simply edit the program and use the Run! again. The new query is executed in a completely new environment. In particular, data that you asserted in a previous query is not available in the next.
If you include example goals inside comments as shown below, they will be used to populate the example menu and make the first goal show in the Goal input field.
/** <examples> ?- loves(X, mia). ?- jealous(X, Y). */
If you use File/Save, the server will save your program in a file with a unique random name and add this name to the URL displayed in the browser's address bar. You can later come back to this source by going to this URL. You can also sent the URL to a friend and let him or her have a look at your program. Anyone can save the program, but the last one wins. In the future, we will add versioning.
Using File/Collaborate ..., you create a TogetherJS session that provides shared editing, chat and voice communication.
You can make SWISH
start with a loaded program using the URL http://swish.swi-prolog.org/
and
providing the parameters below. The URL accepts both `GET` and `POST` requests.
code
, but this part of the code will not be visible in
the editor.
The URL below opens SWISH on a file from GitHub with a default query.
http://swish.swi-prolog.org/?code=https://github.com/SWI-Prolog/swipl-devel/raw/master/demo/likes.pl&q=likes(sam,Food).