Prolog returns yes instead of value

I received the following event: item (C, X, G, P) , (where Cis the number for the product, Xname, Gprice, Pthis is the cost).
When I use the command directly on the prolog console, I get the answer , but when I write the equation , then I will consult the text that I get as the answer . My question is how one day I get the value I want, and at another time I get it true or false? item(n3001,_,_,P)

G = 1.25 X = 100p3(C)-: item(C,_,_,P).yes
P

+4
source share
1 answer

Prolog , p3/1 , .

p3(C) :-
   item(C,_,_,P).

: item(C,_,_,P) , p3(C) . , :

item(n3001,100,1.25,1).

?- p3(n3001).

Prolog C n3001, item(C,_,_,P), . , , Prolog :

   ?- p3(n3001).
yes

, n3001, , P , :

p3(C,P) :-
   item(C,_,_,P).

, P, n3001:

   ?- p3(n3001,P).
P = 1

/4 P , , :

   ?- item(n3001,_,_,P).
P = 1
+5

Source: https://habr.com/ru/post/1676257/


All Articles