next up previous contents
Next: The End of Up: Another Interlude: Input/Output Previous: Input/ Output Channels

Input/ Output and Files

Let us take our input data from a file called ``in''.

 
go:-

see(in),

test,

seen.

We wrap the test/0 predicate into a predicate go/0 which takes input from the specified file ``in''. This file should contain legal Prolog terms ---for the predicate double/2 we want something like:

 
2.

23.

-1.

Now to redirect output to a file named ``out'':

 
go:-

tell(out),

see(in),

test,

seen,

told.

Using the same file ``in'' as previously, ``out'' will contain:
 
4

46



Paul Brna
Mon May 24 20:14:48 BST 1999