我在prolog中遇到了二次方程实现的问题。我知道一些基础知识,但同时我无法理解 swish.swi 控制台的输出。如果您对我的错误提供任何帮助或建议,我将不胜感激。
delta(A, B, C, D):- D is B*B - 4*A*C.
equation(A,B,C,X):- D1<0,delta(A,B,C,D1),X is 0. % or false... but how to retur false there?
equation(A,B,C,X):- D1 =:= 0,delta(A,B,C,D1),X is -B/2*A.
equation(A,B,C,X): D1>0,delta(A,B,C,D1),X is -B-sqrt(D1)/2*A.
equation(A,B,C,X): D1>0,delta(A,B,C,D1),X is -B+sqrt(D1)/2*A.
runnign 后出现两个错误equation(2, 0, 1, X).
Full stop in clause-body? Cannot redefine ,/2
</2: Arguments are not sufficiently instantiated