fix cycle detection in lists by looking backward analogously to the same process for structures (#2130)

This commit is contained in:
Mark
2023-10-24 12:23:05 -06:00
parent d588b18c39
commit 4ab3e23b1f
2 changed files with 29 additions and 0 deletions

View File

@@ -29,6 +29,16 @@ term6(A) :-
A=[B|B],
B=[C|C].
term7(A) :-
B=[C|D],
A=[D|C],
B=[B|D].
term8(A) :-
B=C,
B=[C|_D],
A=[C|_E].
test("acyclic_term_1", (
L = [_Y,[M,B],B|M], acyclic_term(L)
)).
@@ -235,6 +245,16 @@ test("acyclic_term#2125", (
\+ acyclic_term(B)
)).
test("acyclic_term#2130_1", (
term7(T),
\+ acyclic_term(T)
)).
test("acyclic_term#2130_2", (
term8(T),
\+ acyclic_term(T)
)).
main :-
findall(test(Name, Goal), test(Name, Goal), Tests),
run_tests(Tests, Failed),