문제

I'm trying to add two numbers together

add(num1, num2, output) :-
    output is num1 + num2.

Let's say X is 1 and Y is 3, but they're not static, just variables.
add(X, Y, out).

I get a error(instantiation_error,(is)/2) error

Any suggestions?

도움이 되었습니까?

해결책

Prolog is a case-sensitive language and a variable name has to be character sequence made by letters, digits and underscore characters and has to begin with an uppercase letter or underscore character.

Therefore,
add(Num1, Num2, Output) :- Output is Num1 + Num2.
would work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top