changeset 7:bd06de5e669a

*** empty log message ***
author kono
date Fri, 19 Jan 2001 17:21:47 +0900
parents 9b86eb10b61c
children b5ce553f92c6
files infinite.pl
diffstat 1 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/infinite.pl	Fri Jan 19 09:16:27 2001 +0900
+++ b/infinite.pl	Fri Jan 19 17:21:47 2001 +0900
@@ -39,9 +39,9 @@
 retract_all(_).
 
 infinite([S|L]) :-
-    links(_,S),
-    more_only(S),   % search more only node
-    more_only_loop(S,S,L,[]),
+    setof(S,links(S,0),Depth),
+    member(S1,[0|Depth]),
+    more_only_loop(S1,L,[],[S1]),
     assert(found_infinite).
 infinite([]) :-
     found_infinite.
@@ -50,13 +50,16 @@
     state(S,[empty|_],true),!,fail.
 more_only(S) :- number(S).
 
-more_only_loop(S,S0,L,L1) :-
-    links(N,S),
-    more_only_loop1(N,S0,L,L1).
+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_loop1(S,S,L,L) :-!.
-more_only_loop1(N,S,[N|L],L1) :-
+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).
+    more_only_loop(N,S,L,L1,[S|Hist]).
 
 /* end */