changeset 8:b5ce553f92c6

*** empty log message ***
author kono
date Fri, 19 Jan 2001 20:05:42 +0900
parents bd06de5e669a
children 95897517e464
files infinite.pl
diffstat 1 files changed, 36 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/infinite.pl	Fri Jan 19 17:21:47 2001 +0900
+++ b/infinite.pl	Fri Jan 19 20:05:42 2001 +0900
@@ -39,10 +39,8 @@
 retract_all(_).
 
 infinite([S|L]) :-
-    setof(S,links(S,0),Depth),
-    member(S1,[0|Depth]),
-    more_only_loop(S1,L,[],[S1]),
-    assert(found_infinite).
+    setof(S,(links(S,0),integer(S)),Children),
+    more_only_node(0,Children,L,[],[0]).
 infinite([]) :-
     found_infinite.
 
@@ -50,16 +48,40 @@
     state(S,[empty|_],true),!,fail.
 more_only(S) :- number(S).
 
-more_only_loop(S,L,L1,Hist) :-
-    setof(N,links(N,S),Depth),
-    member(S1,Depth),
-    more_only_loop1(S1,L,L1,Hist).
+more_only_node(S,Children,L,L1,Hist) :-
+    more_only(S),!,
+    more_only_loop(S,Children,[S|L],L1,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) :-
+    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_loop1(S,L,L,Hist) :-
-    member(S,Hist),
-    !.
-more_only_loop1(S,[N|L],L1,Hist) :-
-    more_only(N),
-    more_only_loop(N,S,L,L1,[S|Hist]).
+more_only_loop(S,_,L,L,Hist,Seq) :-
+    member(S,Seq),!.		
+    % we find the one
+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(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),
+    % we already know S i not more_only
+    more_only_node1(Children,L,L1,Hist).
+
+more_only_loop1([H|T],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) :-
+    more_only_loop(T,L,L1,Hist,Seq).
 
 /* end */