creep error in Prolog when I find a route

I'm learning Prolog, and I'm getting creep error when I try to find a route. I think what I did is recursion because that's the way to find a route when there's not a straight path.

Here is the code:

route(london,paris).
route(paris,rome).
route(rome,spain).
route(london,berlin).
route(berlin,praga).
route(london,dublin).
route(dublin,berlin).

path(X,Y,[X,Y]):- straight(X,Y).
path(X,Z,[X | other]):- straight(X,Y), path(Y,Z,other). 

when I try to find, let's say the route from London to Rome

path(london,rome,Store).

I get this error:

Exception: (8) straight(london, rome) ? creep

Exception: (7) path(london, rome, _G4705) ? creep

What am I doing wrong? Should I define something else?

Thanks in advance!


ANSWERS:


Your predicate is almost correct. You just need to write the tail of the list as a variable Other instead of an atom other and secondly use your facts route/2 for a straight connection:

path(X,Y,[X,Y]) :-
    route(X,Y).
path(X,Z,[X | Other]) :-
    route(X,Y),
    path(Y,Z,Other).

Now your query works:

   ?- path(london,rome,S).
S = [london,paris,rome] ? ;
no


 MORE:


 ? Ancestor to all reachable node
 ? What is Big O Notation's length measured in?
 ? Big O Notation - O(nlog(n)) vs O(log(n^2))
 ? Time complexity of recursive algorithm for denomination task
 ? Can the elements of a two dimensional array be processed for some output in O(n) time?
 ? Frequency of a number in array faster than linear time
 ? Big-O for while loops with user input
 ? Big o with recursion python
 ? How to merge two sorted arrays into a sorted array?
 ? List of Big-O for PHP functions