home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / library / prolo_c / exampl52.pro < prev    next >
Text File  |  1986-10-06  |  970b  |  40 lines

  1. /* program 52 */
  2. /*
  3.   The program can handle all starting points
  4.   if you remove comments around the added
  5.   clauses. Enter the goal
  6.       route(Town1,Town2,Distance)
  7. */
  8.  
  9. domains
  10.     town     =symbol
  11.     distance =integer
  12.  
  13. predicates
  14.     road(town,town,distance)
  15.     route(town,town,distance)
  16.  
  17. clauses
  18.     road(tampa,houston,200).
  19.     road(gordon,tampa,300).
  20.     road(houston,gordon,100).
  21.     road(houston,kansas_city,120).
  22.     road(gordon,kansas_city,130).
  23.  
  24.     route(Town1,Town2,Distance):-
  25.         road(Town1,Town2,Distance).
  26.     route(Town1,Town2,Distance):-
  27.         road(Town1,X,Dist1),
  28.         route(X,Town2,Dist2),
  29.         Distance=Dist1+Dist2,!.
  30.  
  31. /*  The program can handle all starting points
  32.      with these added clauses
  33.  
  34.     route(Town1,Town2,Distance):-
  35.         road(Town2,Town1,Distance).
  36.     route(Town2,Town1,Distance):-
  37.         road(Town1,X,Dist1),
  38.         route(X,Town2,Dist2),
  39.         Distance=Dist1+Dist2,!.
  40. */