Mercurial > hg > Applications > Lite
view tk/basic @ 22:29cf617f49db default tip
newer CVS version
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 22 Apr 2016 16:47:13 +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