improve cycle detection in detect_list_cycles (#2111)

This commit is contained in:
Mark
2023-10-15 00:58:15 -06:00
parent 7875b96956
commit 3fb2e451a2
2 changed files with 11 additions and 2 deletions

View File

@@ -213,7 +213,7 @@ impl<'a> StacklessPreOrderHeapIter<'a, CycleDetectorUMP> {
}
if temp == self.start {
break;
return self.heap[temp].get_value() == self.current as u64;
}
}

View File

@@ -19,6 +19,11 @@ term4(A) :-
A=[B|C],
C=[C|B].
term5(A) :-
A=[_B|C],
D=[_E|C],
A=[C|D].
test("acyclic_term_1", (
L = [_Y,[M,B],B|M], acyclic_term(L)
)).
@@ -156,6 +161,10 @@ test("acyclic_term#2111_4", (
term4(A), \+ acyclic_term(A)
)).
test("acyclic_term#2111_5", (
term5(A), \+ acyclic_term(A)
)).
test("acyclic_term#2113", (
A=[]*B,B=[]*B, \+ acyclic_term(A)
)).
@@ -175,7 +184,7 @@ main_quiet :-
run_tests_quiet(Tests, Failed),
( Failed = [] ->
format("All tests passed", [])
; format("Some tests failed: ~w~n", [Failed])
; format("Some tests failed", [])
),
halt.