comparison itlstd.pl @ 20:07d6c4c5654b iso-prolog

SICStus v4 (ISO prolog syntax)
author kono
date Thu, 30 Aug 2007 14:16:36 +0900
parents 1c57a78f1d98
children 29cf617f49db
comparison
equal deleted inserted replaced
19:e1d3145cff7a 20:07d6c4c5654b
21 % P & Q = empty,Pn,Qn ; ( Px = Qx = true) 21 % P & Q = empty,Pn,Qn ; ( Px = Qx = true)
22 % more,Pn,Qn & Qx; ( Px = true ) 22 % more,Pn,Qn & Qx; ( Px = true )
23 % more,Pn,(Px & Q) 23 % more,Pn,(Px & Q)
24 % 24 %
25 subterm_init :- 25 subterm_init :-
26 abolish(sb,3), 26 r_abolish(sb,3),
27 asserta((sb(-1,[],[]))), 27 asserta((sb(-1,[],[]))),
28 abolish(sbn,1), 28 r_abolish(sbn,1),
29 asserta(sbn(0)), 29 asserta(sbn(0)),
30 abolish(itl_state,2), 30 r_abolish(itl_state,2),
31 assertz(itl_state(([[]->false]),false)), 31 assertz(itl_state((['->'([],false)]),false)),
32 assertz(itl_state(([[]->true]),0)),!. 32 assertz(itl_state((['->'([],true)]),0)),!.
33 33
34 34
35 std_check(I,J,N) :- 35 std_check(I,J,N) :-
36 sb(N,I,J),!. 36 sb(N,I,J),!.
37 std_check(I,J,N1) :- 37 std_check(I,J,N1) :-
39 assertz(sb(N1,I,J)),!. 39 assertz(sb(N1,I,J)),!.
40 40
41 itlstd(P,List) :- 41 itlstd(P,List) :-
42 setof(N,subterm(P,N),List),!. 42 setof(N,subterm(P,N),List),!.
43 43
44 subterm(P,C->T) :- 44 subterm(P,'->'(C,T)) :-
45 subterm(P,T,[],C0), 45 subterm(P,T,[],C0),
46 sortC(C0,C). 46 sortC(C0,C).
47 47
48 % bubble sort 48 % bubble sort
49 sortC([],[]). 49 sortC([],[]).