num(N) :- No=N, write(No), nl.
check(S) :- No==S -> write(Ok) ; write(Not ok).
When i call num(5), it prints 5. However after calling num(5), when i call check(5), it prints Not ok. I think its because of scope of variables..How can i make it work, i mean variable No like a global variable, so that i can check its value in other clauses?
you can use the global variables of swipl or assert/retract
however, using global variables is a bit against the declarative programming paradigm since it violates referential transparency