Реферат: Логические задачи на языке программирования Prolog
operation("-",X,Y):-Z=X-Y,
write(X,"-",Y,"=",Z),
nl.
operation("*",X,Y):-Z=X*Y,
write(X,"*",Y,"=",Z),
nl.
operation("/",X,Y):-Z=X/Y,
write(X,"/",Y,"=",Z),
nl.
Результат: Z=8+2 Z=8-2 Z=8*2 Z=8/2
Z=10 Z=6 Z=16 Z=4
1 Solution 1 Solution 1 Solution 1 Solution
2. Реализовать эту же программу с внутренней целью
predicates
operation(symbol,real,real)
Goal
write(“Vvedite chisla”),
nl,
readreal(X),
nl,
readreal(Y),
nl,
operation(“+”,X,Y),
operation(“-“,X,Y),
operation(“*”,X,Y),
operation(“/ “,X,Y).
clauses
operation("+",X,Y):-Z=X+Y,
write(X,"+",Y,"=",Z),