Answer the question
In order to leave comments, you need to log in
How to run code in prolog?
Help me out, I have Prolog in my studies, but I don’t accept it at all in any way.
Help who understands it.
count(X,X,1):-!.
count(_,Y,0):-atomic(Y),!.
count(X,Y,N):-
Y=..[_|Subs],
count_list(X,Subs,N).
count_list(_,[],0):-!.
count_list(X,[H|T],N):-
count(X,H,N1),
count_list(X,T,N2),
N is N1+N2.
start:-read(S),read(Sl),count_list(Sl,S,N),write('N = '),write(N).
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