E
E
Evgeny Nikolaev2018-03-01 02:46:37
Prolog
Evgeny Nikolaev, 2018-03-01 02:46:37

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).

I honestly stole this code, but I don’t know how to run it.
I need to pass two parameters to the start ...
Syntactically, I can’t understand how this is done, as soon as I didn’t try, it gives either a syntax error or "procedure `(A:-B)' does not exist"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question