simplify stackless iterator is_cyclic (#2111)
This commit is contained in:
@@ -272,14 +272,9 @@ impl<'a, UMP: UnmarkPolicy> StacklessPreOrderHeapIter<'a, UMP> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn is_cyclic(&self, var_current: usize, var_next: usize) -> bool {
|
fn is_cyclic(&self, var_current: usize, var_next: usize) -> bool {
|
||||||
if self.heap[var_next].is_var() {
|
if self.heap[var_next].is_var() {
|
||||||
var_current != var_next && self.current + 1 != var_current
|
!self.heap[var_next].get_forwarding_bit() && var_current != var_next
|
||||||
} else if self.heap[var_next].is_ref() {
|
|
||||||
// the cell var_next in the second branch contains its original
|
|
||||||
// value whether var_next is marked or unmarked, meaning the
|
|
||||||
// is_compound check is well-founded in either case.
|
|
||||||
self.heap[var_next].get_forwarding_bit()
|
|
||||||
} else {
|
} else {
|
||||||
false
|
self.heap[var_next].is_ref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ term3(A) :-
|
|||||||
D=[C|_E],
|
D=[C|_E],
|
||||||
A=[C|D].
|
A=[C|D].
|
||||||
|
|
||||||
|
term4(A) :-
|
||||||
|
A=[B|C],
|
||||||
|
C=[C|B].
|
||||||
|
|
||||||
test("acyclic_term_1", (
|
test("acyclic_term_1", (
|
||||||
L = [_Y,[M,B],B|M], acyclic_term(L)
|
L = [_Y,[M,B],B|M], acyclic_term(L)
|
||||||
)).
|
)).
|
||||||
@@ -123,6 +127,19 @@ test("acyclic_term_26", (
|
|||||||
T = [[T, _], 1], \+ acyclic_term(T)
|
T = [[T, _], 1], \+ acyclic_term(T)
|
||||||
)).
|
)).
|
||||||
|
|
||||||
|
test("acyclic_term_27", (
|
||||||
|
T = str(A,A), acyclic_term(T)
|
||||||
|
)).
|
||||||
|
|
||||||
|
test("acyclic_term_28", (
|
||||||
|
T = str(A,A,A), acyclic_term(T)
|
||||||
|
)).
|
||||||
|
|
||||||
|
test("acyclic_term_29", (
|
||||||
|
A = s(B, d(Y)), Y = B, acyclic_term(A),
|
||||||
|
acyclic_term(B), acyclic_term(Y)
|
||||||
|
)).
|
||||||
|
|
||||||
test("acyclic_term#2111_1", (
|
test("acyclic_term#2111_1", (
|
||||||
term1(A), \+ acyclic_term(A)
|
term1(A), \+ acyclic_term(A)
|
||||||
)).
|
)).
|
||||||
@@ -135,6 +152,10 @@ test("acyclic_term#2111_3", (
|
|||||||
term3(A), \+ acyclic_term(A)
|
term3(A), \+ acyclic_term(A)
|
||||||
)).
|
)).
|
||||||
|
|
||||||
|
test("acyclic_term#2111_4", (
|
||||||
|
term4(A), \+ acyclic_term(A)
|
||||||
|
)).
|
||||||
|
|
||||||
test("acyclic_term#2113", (
|
test("acyclic_term#2113", (
|
||||||
A=[]*B,B=[]*B, \+ acyclic_term(A)
|
A=[]*B,B=[]*B, \+ acyclic_term(A)
|
||||||
)).
|
)).
|
||||||
@@ -143,14 +164,6 @@ test("acyclic_term#2114", (
|
|||||||
A=B*B, acyclic_term(A)
|
A=B*B, acyclic_term(A)
|
||||||
)).
|
)).
|
||||||
|
|
||||||
test("acyclic_term_27", (
|
|
||||||
T = str(A,A), acyclic_term(T)
|
|
||||||
)).
|
|
||||||
|
|
||||||
test("acyclic_term_28", (
|
|
||||||
T = str(A,A,A), acyclic_term(T)
|
|
||||||
)).
|
|
||||||
|
|
||||||
main :-
|
main :-
|
||||||
findall(test(Name, Goal), test(Name, Goal), Tests),
|
findall(test(Name, Goal), test(Name, Goal), Tests),
|
||||||
run_tests(Tests, Failed),
|
run_tests(Tests, Failed),
|
||||||
|
|||||||
Reference in New Issue
Block a user