0

I am working on a homework, and have it pretty much done. Easiest CS homework I've done in recent memory. It's to write a Prolog program to find flight paths between different cities. So

oneStop(X,Y)

will find if the two cities have one stop between them, and so on for two, three, and four stops, as well as

 flightExists(X, Y) 

which finds if a paths exists in general. They all work great except that the output I get doesn't list out the entire flight path, only whichever X/Y I replace with the variable. How do I list out all the cities in between?

mmf1102
  • 61
  • 1
  • 12
  • 2
    this question make me think it's time for you to review earlier homework... – CapelliC Nov 24 '15 at 12:12
  • Add an argument somewhere in one of your predicates that carries the list of places visited when determining the flight. Obviously, it traverses a flight path to determine that there is one. So you just have to build it into a list as you go. Should be just as easy as the rest of it was. :) – lurker Nov 24 '15 at 12:37
  • The class is about learning programming language concepts, and we're using a bunch of different 'micro' languages (uSmallTalk uScheme etc.) which they built interpreters for. This is the only Prolog project we're doing, and it's supposed to just be a simple one, especially since "uProlog" is essentially the full thing. – mmf1102 Nov 24 '15 at 12:56
  • 1
    It's simple to add a list argument, and list processing is fundamental in Prolog. – lurker Nov 24 '15 at 13:15

0 Answers0