Category : Files from Magazines
Archive   : AIJLAG87.ZIP
Filename : UTILITY.ARI

 
Output of file : UTILITY.ARI contained in archive : AIJLAG87.ZIP
% Top Level Compiler Procedures and Utilities
% LLO 12-30-85
% File: UTILITY.ARI
% (C) 1986,1987 Louis L. Odette. All Rights Reserved.

/* These are the top-level compiler procedures */

% compile_file may need to be adapted for your file system

compile_file(File) :-
seeing(Oldfile),see(File),repeat,
compile(P,Code),
(is_endfile(Code) ; write_code(P,Code),fail),
seen,see(Oldfile).

compile(P,Code) :-
compile_clause(P,Nvars,Code),
(is_endfile(Code) ;
(retract(procedure(P,Clauses)),
concat(Clauses,[clause(Nvars,Code)],NewClauses),
assert(procedure(P,NewClauses));
assert(procedure(P,[clause(Nvars,Code)])))),!.

compile_clause(P,Nvars,Code) :-
get0(Char),
(is_endfile(Char),Code = Char;
read_until(Char,".",Rest),!,
chars_to_words([Char|Rest],Sent),
clause(Vars,[],Cd,P,Sent,_),nrev(Cd,Code),
is_newline(E),read_until([E],_),
memberchkN(-1,Vars,-1,Nvars)).


/* Utilities */

% member

member(X,[X|_]).
member(X,[_|L]) :- member(X,L).

% memberchk

memberchk(X,[X|_]) :- !.
memberchk(X,[_|T]) :- memberchk(X,T).

% memberchkN

memberchkN(X,[X|_],M,N) :- N is M+1,!.
memberchkN(X,[_|T],L,N) :- M is L+1,memberchkN(X,T,M,N).

% naive reverse

nrev([X|L0],L) :-
nrev(L0,L1),concat(L1,[X],L).
nrev([],[]).

% concatenate

concat([],L,L).
concat([X|L1],L2,[X|L3]) :- concat(L1,L2,L3).

% write_code

write_code(P,Code) :-
write(P),nl,write(Code),nl,!.



  3 Responses to “Category : Files from Magazines
Archive   : AIJLAG87.ZIP
Filename : UTILITY.ARI

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/