I am very new to Prolog and I have a problem when my variable seems to be forgotten
test(S) :-
X = 'testing',
(S = y, write(X) );
(S = n, write(X) ).
Launch
test(y)
Prints the text as expected, but
test(n)
displays
_L160
What do I suppose means that the variable is not constant? Why is this happening?
I know that he can spit on two predicates, for example:
test(y) :- X = 'testing', write(X).
test(n) :- X = 'testing', write(X).
but my actual problem is a much larger predicate that cannot be simplified in this way.
source
share