# HG changeset patch # User kono # Date 979904252 -32400 # Node ID 95897517e4642c7bd88dc923d30569b93fd62888 # Parent b5ce553f92c6075aa85ad05fa30b1cfc3019a876 some how infinite.pl works first. diff -r b5ce553f92c6 -r 95897517e464 infinite.pl --- a/infinite.pl Fri Jan 19 20:05:42 2001 +0900 +++ b/infinite.pl Fri Jan 19 20:37:32 2001 +0900 @@ -38,9 +38,9 @@ retract(X),fail. retract_all(_). -infinite([S|L]) :- - setof(S,(links(S,0),integer(S)),Children), - more_only_node(0,Children,L,[],[0]). +infinite(L) :- + setof(S,(links(S,1),integer(S)),Children), + more_only_node(1,Children,L,[],[1]). infinite([]) :- found_infinite. @@ -48,37 +48,39 @@ state(S,[empty|_],true),!,fail. more_only(S) :- number(S). -more_only_node(S,Children,L,L1,Hist) :- +more_only_node(S,[S1|Children],[S|L],L1,Hist) :- more_only(S),!, - more_only_loop(S,Children,[S|L],L1,Hist,[S]). + more_only_loop(S1,Children,L,L1,[S|Hist],[S]). more_only_node(_,Children,L,L1,Hist) :- % goto one depth deeper more_only_node1(Children,L,L1,Hist). -more_only_node1([H|T],L,L1,Hist) :- +more_only_node1([H|_],L,L1,Hist) :- setof(S,(links(S,H),integer(S)),Children), more_only_node(H,Children,L,L1,Hist). more_only_node1([_|T],L,L1,Hist) :- more_only_node(T,L,L1,Hist). -more_only_loop(S,_,L,L,Hist,Seq) :- - member(S,Seq),!. +more_only_loop(S,_,L,L,_Hist,Seq) :- + member(S,Seq),!, + assert(found_infinite). % we find the one -more_only_loop(S,_,L,L,Hist,Seq) :- +more_only_loop(S,_,L,L,Hist,_Seq) :- member(S,Hist),!, fail. % end of this branch -more_only_loop(H,Children,L,L1,Hist,Seq) :- +more_only_loop(H,_,[H|L],L1,Hist,Seq) :- more_only(H),!, % still in the false interval - more_only_loop1(Children,L,L1,Hist,Seq). -more_only_loop(_,[S|_],L,L1,Hist,_) :- - % false interval end start new search in depth first way + setof(S,(links(S,H),integer(S)),Children), + more_only_loop1(Children,L,L1,[H|Hist],[H|Seq]). +more_only_loop(H,[S|_],[H|L],L1,Hist,_) :- + % false interval ends, start new search in depth first way setof(S,(links(S,H),integer(S)),Children), % we already know S i not more_only - more_only_node1(Children,L,L1,Hist). + more_only_node1(Children,L,L1,[H|Hist]). -more_only_loop1([H|T],L,L1,Hist,Seq) :- +more_only_loop1([H|_],L,L1,Hist,Seq) :- setof(S,(links(S,H),integer(S)),Children), more_only_loop(H,Children,L,L1,Hist,Seq). more_only_loop1([_|T],L,L1,Hist,Seq) :-