Hi i have to make a prolog rule which finds all stations on a particular underground line.
I have a list of fact about each station and which line it is found on.
The format of the rule has to be : line(Line,ListOfStations)
i am unsure of how to implement the fact database and how to proceed with making the rule in order for this to work.
i have thought of make a Fact for example, ListOfStations(central,[nh,lg,oc,tc,cl,ls,bg ]). for each of the tube lines. However one error im getting is a syntax error i do not understand what it wants me to do. Another is the the rule would look something like;
online(Line,Location):- ....some rule here... and would print out all of the stations found in that ListOfstations.
But from what i understand the user would have to enter which 'line' i want to use and the list of all the stations on that line?
I have tried the following but it doesnt work and i do not know why...
%Q3 : Finds Which stations are on a particular line
% A line has ListOfStations that it crosses if each station is on the
% given line.
% The rule collects each station and stores them using the setOf.
%
line(line,ListofStations) :- setof(Locations,online(Line, Locations),ListOfStations).
% A station is on a line if given Station1 on line1 is also on the line
% where the given station and station1 are teh same.
%
online(Line, Station) :- location(Location1,Line1), shareitem(Line,Line1, Line2), Location = Location1.
i dont really understand how this is supposed to work
can you help me out with getting this sorted? Note i am very new to prolog. thanks