add(0,Y,Y).
add(s(X),Y,Z):-
add(X,Y,Z1),
Z is s(Z1).
why always resulting in false why is the compiler telling me Arithmetic : 's(_2676)' is not a function
add(0,Y,Y).
add(s(X),Y,Z):-
add(X,Y,Z1),
Z is s(Z1).
why always resulting in false why is the compiler telling me Arithmetic : 's(_2676)' is not a function
Your are confusing predicate calls with compound terms. You have not defined
s/1
predicate. So the compiler throws an error.is
is not a generic assignment, it is a arithmetic evaluator. You should use=
instead.The following should work. Here when I write
s(X)
, this is not a predicate call but a compound term.or this