Answer the question
In order to leave comments, you need to log in
How does this program work in Prolog?
Given a program in Prolog. Can you please explain how it works?
count(_,[],0).
count(X,[X|L],N):-count(X,L,N2),N is N2 + 1.
count(X,[_|L],N):-count(X,L,N).
p([],_,[]).
p([X|V],N,[X|L]):-count(X,[X|V],K),K >= N, delete(V,X,V2),p(V2,N,L).
p([X|V],N,L):-delete(V,X,V2),p(V2,N,L).
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question