j'ai faits comme:comparant deux faits Prolog
like(sara,'data base',3).
like(sara,'math',3).
like(sara,'physics',3).
like(sara,'law',3).
like(sara,'history',5).
like(sara,'science',1).
like(tom,'chemistry',3).
like(tom,'data base',2).
like(tom,'logic',3).
like(tom,'law',3).
like(tom,'history',3).
like(tom,'science',3).
:- dynamic same_like/3.
et je veux comparer les faits pour trouver un sujet à la fois sara et tom comme, mais avec un niveau différent, donc ce que je fais est que:
comp1 :-
like(sara, NofC1, X),
like(tom, NofC2, Y),
NofC1 = NofC2,
asserta(same_like(sara, NofC1, X)),
asserta(same_like(tom, NofC2, Y)),
same_like(sara, NC1, A),
same_like(tom, NC2, B),
NC1 = NC2,
A =\= B,
write('sara and tom like the same subject " '),
write(NC1),
write(' " .But with different level, sara= '),
write(A),
write(' And tom = '),
write(B),
nl,
fail.
la réponse était bonne, mais il y a une répétition dans la réponse:
sara and tom like the same subject " data base " .But with different level, sara= 3 And tom = 2
sara and tom like the same subject " data base " .But with different level, sara= 3 And tom = 2
sara and tom like the same subject " history " .But with different level, sara= 5 And tom = 3
sara and tom like the same subject " data base " .But with different level, sara= 3 And tom = 2
sara and tom like the same subject " science " .But with different level, sara= 1 And tom = 3
sara and tom like the same subject " history " .But with different level, sara= 5 And tom = 3
sara and tom like the same subject " data base " .But with different level, sara= 3 And tom = 2
false
. La question est de savoir comment puis-je supprimer cette répétition ??? :(
je fais ça, mais si je l'utilise! pas toute la réponse sera imprimée :( – user1885169