Code Comments
Programming Forum and web based access to our favorite programming groups.Hey any help is greatly appreciated complete newb to prolog, trying to produ ce a route finder, i'm given this program to start with; % chicago.pl :-use_module(library(lists)). %road/3 road(bourt,chicago,5). road(chicago,canter,30). road(canter,gaton,30). road(canter,idmouths,25). road(staple,onbur,20). road(staple,gaton,40). road(staple,tiv,15). road(gaton,tivworthy,30). road(onbur,idmouths,10). road(onbur,tiv,10). What i need help with is i have to produce a predicate trip/3 which is a bi- directional version of the above road/3, i think it only involves writing 2 rules of which the comments are; %trip/3 % rule 1 % you can make a trip of distance DIST from A to B % if there is a road of distance DIST from A to B % rule 2 % you can make a trip of distance DIST from A to B % if there is a road of distance DIST from B to A Any help with this would be appreciated. Thanks.
Post Follow-up to this message%trip/3 trip(A,B,DIST) :- road(A,B,DIST). trip(A,B,DIST) :- road(B,A,DIST).
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.