Logtalk 2.16.0 release files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1014 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
33
Logtalk/examples/operators/reverse.lgt
Normal file
33
Logtalk/examples/operators/reverse.lgt
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
:- object(reverse).
|
||||
|
||||
|
||||
:- info([
|
||||
version is 1.0,
|
||||
author is 'Paulo Moura',
|
||||
date is 2004/2/16,
|
||||
comment is 'Reads and writes a simple table of facts from and to files for testing operator handling code.']).
|
||||
|
||||
:- op(500, xfx, next).
|
||||
:- op(500, xfx, previous).
|
||||
|
||||
:- initialization(reverse_file).
|
||||
|
||||
|
||||
reverse_file :-
|
||||
open('next.txt', read, RStream),
|
||||
open('previous.txt', write, WStream),
|
||||
read(RStream, Term),
|
||||
process(Term, RStream, WStream).
|
||||
|
||||
process(end_of_file, RStream, WStream) :-
|
||||
close(RStream),
|
||||
close(WStream).
|
||||
|
||||
process(X next Y, RStream, WStream) :-
|
||||
write(WStream, Y previous X), write(WStream, '.'), nl(WStream),
|
||||
read(RStream, Next),
|
||||
process(Next, RStream, WStream).
|
||||
|
||||
|
||||
:- end_object.
|
Reference in New Issue
Block a user