I have a problem with a small program that i made. Below is the part with the problem.
failed(X, C, Y) :-
registered_for(
student(id(X),_,_,_,_,_),
course(name(C),year(Y),_),absences(A)),
A>2.
failed(X, C, Y) :-
grades(
course(name(C),year(Y),_),
student(id(X),_,_,_,_,_),_,normal(G),_,_),
G<5.
count_failed(X, C, Y, N) :-
failed(X, C, Y),
append(L, C, L),
length(_,L,N).
The first 2 lines are working as intended. The problem is somewhere in the last. I want to add C on the list L but all i get is “ERROR : Out of global stack”. I am using SWI-prolog.
If needed i can post the rest of the code. Thanks in advance for your time and effort 🙂
Wouldn’t you use
findallto assemble the list?The reason for the stackoverflow is probably append(L, C, L), since L is never unified to anything inside this clause.