I have the next code in a file called "testing.pl":
fact(1).
fact(2).
fact(3).
funcA(X) :- funcB(X).
funcB(X) :- fact(X).
testing :- funcA(_X).
Then, in SWI-Prolog interpreter I query funcA(X).
and the output is:
X = 1 ;
X = 2 ;
X = 3.
But, whenever I query testing.
the output is:
true ;
true ;
true.
So, my questions is:
How can I use the conclusion of a rule as a premise of another rule (funcA(X)
at the right of testing
), but having the same effect as if I query that premise (funcA(X)
)?
In the example above, I would like to write testing.
at some point of my "testing.pl" file and to get the funcA(X) to do the same like when I query with the interpreter, so funcB(X) will check for all values that X can take from fact(N) and return it.
My desire result would be to write testing.
and to get on screen:
X = 1 ;
X = 2 ;
X = 3.
Thanks.