0

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?

false
  • 10,264
  • 13
  • 101
  • 209
shoconinja
  • 195
  • 1
  • 3
  • 11

1 Answers1

1

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.

stuhlo
  • 1,479
  • 9
  • 17