OrenIshShalom
OrenIshShalom

Reputation: 7162

Running a single non-interactive swi-prolog query

I'm trying to run the following query:

edge(1,2).
edge(2,3).
edge(3,4).

connected(X,Y) :- edge(X,Y).
connected(X,Y) :- edge(X,Z), connected(Z,Y).

result :- connected(1,4).
main :- format('%d', result).

But when I try to compile and run, I get inside an infinite loop:

$ swipl -nodebug -g true -O -q --toplevel=main --stand_alone=true -o main -c main.pl
$ ./main
ERROR: Format error: too many arguments
ERROR: In:
ERROR:    [4] format('%d',result)
%d
# ... the above 3 ERRORs keep running infinitely ...

Related (an epsilon-more complicated than): this post

Upvotes: 0

Views: 78

Answers (0)

Related Questions