view tk/basic @ 10:f2aa38ce0787

add state display.
author kono
date Fri, 19 Jan 2001 23:14:00 +0900
parents 1c57a78f1d98
children
line wrap: on
line source

:- multifile tclause/2.

% Basic Composite
%    fact is not allowed. use a:-true form.
%    commented out one is defined internally for efficiency
% @(A)	:- more,next(A).
% #(A)	:- A,next(#(A)).
% [](A)	:- A,next([](A)).
% (A && B)	:- (A,more) & B.
% (A &@ B)	:- A & @B.
% keep(A)	:- next(keep(A)),ifMore(A).
% fin(A)	:- next(fin(A)),ifEmpty(A).
% gets(A,B)	:- keep(@A = B).
% (A<-B)	:- A=B,stable(C),fin(A=C).
(A<-B)		:- C<--B,fin(A=C).
skip		:- @empty.
<>(A)		:- true & A.
halt(A)		:- A,!,empty.
halt(A)		:- @(halt(A)).
stable(A)	:- gets(A,A).
% Framing
% A <= B		:- more, <>(A:=B).
A // B		:- process(A),process(B).
frame(A,B)	:- frame(A), B.
frames([H|T],B)	:- frame(H),frames(T,B).
frames([],B)	:- B.
readonlys([H|T],B)	:- readonly(H),readonlys(T,B).
readonlys([],B)	:- B.
% A:=B		:- forall_parent(flag(A,assign)),@A=B.
% readonly(A)	:- flag(A,stay).
% Closures
*(_)		:- empty.
*(A)		:- more,A & *(A).
% These are very slow in interpreter
while(A,B)	:- (A,!,more,B) & while(A,B).
while(_,_)	:- empty.
(if A then B else _)	:- A,!,B.
(if _ then _ else C)	:- C.
(_ else _)	:- fail.
(if A then B)	:- A,!,B.
(if _ then _)	:- true.
% end