I'm relatively new to Prolog and my aim from this code is to try and find all routes between all defined edges. Prolog should output me the full route from the inputted start to destination. However I keep getting an error bash: -c: line 1: syntax error near unexpected token ('
I was wondering if im going about this in the right way? or maybe I'm being blind to silly mistakes..
Here is my code.
edge(o,p1).
edge(p1,k).
edge(k,l).
edge(l,c).
edge(c,b).
edge(c,w).
edge(c,m).
edge(l,p2).
path(X,Y,Path) :- path(X,Y,[X],Q), reverse(Q,Path).
path(X,Y,Visited,[Y|Visited]) :- edge(X,Y).
path(X,Y,Visited,Path) :-
edge(X,Z),
Z \== Y,
\+ member(Z,Visited),
path(Z,Y,[Z|Visited],Path).
The TEST CASE I was trying to run was
path(o, m, Path).
edit: i ran it with swipl and these errors were returned image here, it didnt let me upload an image sorry