From fraser.mathieson@stir.ac.uk  Mon Mar 13 13:19:48 2000
Received: from clyde.stir.ac.uk (clyde.stir.ac.uk [139.153.13.35])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id NAA03348
	for <prolog@swi.psy.uva.nl>; Mon, 13 Mar 2000 13:19:48 +0100 (MET)
Received: from findhorn.stir.ac.uk (findhorn.stir.ac.uk [139.153.13.5])
          by clyde.stir.ac.uk (8.8.8/8.8.4) with ESMTP
	  id MAA01687 for <prolog@swi.psy.uva.nl>; Mon, 13 Mar 2000 12:18:16 GMT
Received: by findhorn.stir.ac.uk with Internet Mail Service (5.5.2650.21)
	id <F7F9LH8V>; Mon, 13 Mar 2000 12:19:45 -0000
Message-ID: <0B17AD22BF66D1119981006097BCB3A3032364D3@findhorn.stir.ac.uk>
From: Fraser Mathieson {Students} <fraser.mathieson@stir.ac.uk>
To: "'prolog@swi.psy.uva.nl'" <prolog@swi.psy.uva.nl>
Subject: Printing to a file
Date: Mon, 13 Mar 2000 12:19:42 -0000
Return-Receipt-To: Fraser Mathieson {Students}
	 <fraser.mathieson@findhorn.stir.ac.uk>
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Content-Type: text/plain

Hi again,

I sent an e-mail last week, and now I have got a new problem on the program
I am trying to write.

This time its:

	Search the list of train journeys and print out in a different file,
all the train journeys 	from one station to the next, including the
intermediate stations.

The journeys are, again, in the form of:
	train(['Stirling',849,'Glasgow',935]).
	train(['Stirling',905,'Edinburgh',958]).
	train(['Aberdeen',705,'Dundee',825,'Perth',847,'Stirling',
		 919,'Glasgow',950]).
	train(['Stirling',935,'Edinburgh',1028]).
	train(['Stirling',949,'Glasgow',1035]).
	train(['Stirling',1005,'Edinburgh',1100]).
	train(['Inverness',720,'Perth',928,'Stirling',1008,
		 'Edinburgh',1047,'London',1600]).

The precdicate:
	directJourneys(City1,City2)
must be used.

I have used the following, and it is not doing the right thing.
 	from(X,[X|L],[X|L1]).
	from(X,[X|L,S) :- H \= X, from(X,L,S).
	to(X, [X|_], [X|_]).  % discard the part after X
	to(X, [H|L], [H|L1]) :-  % keep H in the answer
      	  H \= X, to(X,L,L1).

	directJourneys(City1,City2) :-
		train(List),
		tell('assignment.txt'),
		fromTo(City1,City2,X,S),
		fail,
		told.

	fromTo(City1,City2,X,S) :-
		from(City1,X,S1),
		to(City2,S1,S),
		write(S), nl.

Could anybody tell me how to sort this.

Cheers

Fraser Mathieson
(fraser.mathieson@stir.ac.uk)

