Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Sep 27, 2024
1 parent d0ed543 commit b9b8550
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions samples/tco.pl
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@
test2(0) :- !, statistics, nl, fail.
test2(N) :- f, N1 is N-1, test2(N1).

f(1).

test3(0) :- !, statistics, nl, fail.
test3(N) :- f(_), N1 is N-1, test3(N1).

% No local vars & no structures, yet not recovered...

f(_, _).

test3(0) :- !, statistics, fail.
test3(I) :- f(I, _), I2 is I-1, test3(I2).
test4(0) :- !, statistics, fail.
test4(I) :- f(I, _), I2 is I-1, test4(I2).

main :-
test1(100000);
test2(200000);
test3(300000);
test4(400000);
true.

3 changes: 2 additions & 1 deletion src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,9 @@ static void commit_frame(query *q)
}

// Matching a fact (see disjunction in bif_control.c)...
// !q->has_vars ??? test for no vars left ?

if (q->pl->opt && !body && last_match && is_det && !cl->nbr_vars) {
if (q->pl->opt && !body && last_match && !q->has_vars && !cl->nbr_vars) {
leave_predicate(q, q->st.pr);
drop_choice(q);
//cut(q); // ???
Expand Down

0 comments on commit b9b8550

Please sign in to comment.