I get several results with the same outputs.
I want to get jack,jane
only one time, but I get it two times.
How can I avoid this? I tried setof
but I couldn't get it done. Please can someone help me on this?
I get several results with the same outputs.
I want to get jack,jane
only one time, but I get it two times.
How can I avoid this? I tried setof
but I couldn't get it done. Please can someone help me on this?
This question is duplicated in "How to stop repetitions in rules in prolog".
An answer is to do something like this:
solve :-
marriedcouple(Dad, Mum),
not(found(marriedcouple(Dad, Mum))),
assert(found(marriedcouple(Dad, Mum))),
write([Dad, Mum]),
nl,
fail.
Read the full answer for more detail.