jnpnshr411
Programmer
Hello all,
this is my first time on these forums. I am not new to programming at all, but am very lost with prolog. I have been reading through "Learn Prolog Now!"
they as me to build a predicate that would let me know if i can travel from one place to another.
the assertions that I have are
I wrote a functor that will answer yes if there is some way to get from point X to Y. However I want to make a predicate called travel/3 that will build a list of travel points needed to go from X to Y.
Can someone lead my on the right path to build the list?
thank you for any help
this is my first time on these forums. I am not new to programming at all, but am very lost with prolog. I have been reading through "Learn Prolog Now!"
they as me to build a predicate that would let me know if i can travel from one place to another.
the assertions that I have are
Code:
byCar(auckland,hamilton).
byCar(hamilton,raglan).
byCar(valmont,saarbruecken).
byCar(valmont,metz).
byTrain(metz,frankfurt).
byTrain(saarbruecken,frankfurt).
byTrain(metz,paris).
byTrain(saarbruecken,paris).
byPlane(frankfurt,bangkok).
byPlane(frankfurt,singapore).
byPlane(paris,losAngeles).
byPlane(bangkok,auckland).
byPlane(losAngeles,auckland).
I wrote a functor that will answer yes if there is some way to get from point X to Y. However I want to make a predicate called travel/3 that will build a list of travel points needed to go from X to Y.
Code:
travel(X,Y) :- byCar(X,Y),byPlane(X,Y),byTrain(X,Y).
travel(X,Y) :- byCar(X,Z) ; byTrain(X,Z) ; byPlane(X,Z), travel(Z,Y).
Can someone lead my on the right path to build the list?
thank you for any help