I’m very new to Prolog, and i’m having a problem where my variable seems to be forgotten
test(S) :-
X = 'testing',
(S = y, write(X) );
(S = n, write(X) ).
Running
test(y)
Prints out the text as expected, but
test(n)
prints out
_L160
Which i assume means the variable is uninstantsiated? Why is this happening?
I know it can spit it into two predicates like:
test(y) :- X = 'testing', write(X).
test(n) :- X = 'testing', write(X).
but my actual problem is in a much larger predicate that cant be simplified like this.
The disjunction (;) currently succeeds by either:
OR, if that fails, backtrace and
Add some parentheses to make it work as intended.