프롤로그에서는 재귀를 사용하여 작업하고 머리글과 꼬리를 사용하는 것이 좋습니다. 인스턴스화 된 3 개의 모든 vaiables가 있으므로 프롤로그가 예를 들어 a와 같은 용어를 인스턴스화 할 수 없습니다.
removable(A,B,N) :-
removable(A,B,N,0). % This is just another call with accumulator.
removable(L,L,Acc,Acc). %This is your base case, When Acc and Acc will equal then prolog will find one succesive branch.
removable([],[],_,_). %This base case says that no matter what values Accs have if a list is emepty then substitue other also with empty list and return result.
removable(R,[H|T],N,Acc) :- %This predicates removes H and keeps counting when removed elements equal to N then first(base case) will succeed.
NewAcc is Acc + 1,
removable(R,T,N,NewAcc).
.