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