Route Finding

From: Joe_Baker (poppa_baker_at_nospamhotmail.com)
Date: 05/05/04


Date: Wed, 05 May 2004 11:31:47 -0400

Hi, I am wrote a program to find a route between two places, like this:

link(a, b).
link(b, c).
etc..

route(From, To):-
        link(From, To)

route(From, To):-
        link(From, Via),
        route(Via, To).

This works fine, I then tried to modify it by outputting the route
followed.
My attempt was.

link(a, b).
link(b, c).
link(c, d).
etc...

route(From, To):-
        route(From, To, From).

route(From, To, Route):-
        link(From, To),
        print_route([To|Route]).

route(From, To, Route):-
        link(From, Via),
        route(Via, To, [Via|Route]).

print_route([]).

print_route([Head|Tail]):-
        write(Head),
        write(' '),
        print_route(Tail).

The result of any query is always no, and a list is written, which does
not seem to make much sense!

If anyone could help i would be very grateful!
Joe



Relevant Pages

  • Re: Enter MULTIPLE Items in a Query (e.g. [Name:] ??
    ... >The user running the query will be prompted for first names. ... Here's the SQL view of that query. ... The field that is being querried on is "route" ... the chance of entry errors will hopefully be ...
    (microsoft.public.access.queries)
  • ENTER MULTIPLE Items in a Query Pop-Up PROMPT e.g. [Name:]
    ... >The user running the query will be prompted for first names. ... Here's the SQL view of that query. ... The field that is being querried on is "route" ... Seperating each by a comma will not be a problem. ...
    (microsoft.public.access.queries)
  • Follow up to earlier Select Query Question
    ... I wrote a query to pull out one unique route number along with the FirstOf ... fields from my original Route Info table using the suggested method below -- ... of equipment and the routes to which each piece was assigned -- let's call it ...
    (microsoft.public.access.queries)
  • Re: Select Query Question
    ... I am trying to do a Select Query. ... multiple listings for one Route# but only one of those is correct. ... and you just want to pull whatever record Access happens to ... SELECT DISTINCT FROM Table2; ...
    (microsoft.public.access.queries)
  • Re: Select Query Question Continued
    ... original Route Info table using the suggested method below -- let's call it ... the Route Info query. ... I have since adjusted the Combo query to pull in the route Information from ...
    (microsoft.public.access.queries)