Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top