Ce doit pas être grand chose.
Mais cela me montre que je n'ai pas encore compris ce p%%% de langage attirant.
Soit la base de données :
Je veux écrire un prédicat qui intersectionne les interdits.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 crazyright(zut, a). crazyright(zut, b). crazyright(zut, c). crazyright(zut, d). crazyright(zic, a). crazyright(zic, b). crazyright(zic, z). crazyright(zouc, a).
Par exemple, ( delCrazyRight([zut,zic,zouc], [a]), ou
delCrazyRight([zut,zic], [a,b])
ou delCrazyRight([zut], [a,b,c,d])
etc.
En exécutant le deboggueur de swi prolog (guitracer, trace) sur le programme suivant, je vois passer ma réponse dans Z, mais quand prolog backtrack , la donnée se perd, et l'ensemble se termine par NO.
Que dois-je faire ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 delCrazyRight([],_) :- !. delCrazyRight([F|Q],[]) :- !, findall(ForbidTag,crazyright(F, ForbidTag),ListofForbidTags), list_to_set(ListofForbidTags, SetofForbidTags), delCrazyRight(Q,SetofForbidTags). delCrazyRight([F|Q],InterForbidtags) :- InterForbidtags\=[], !, findall(ForbidTag,crazyright(F, ForbidTag),ListofForbidTags), list_to_set(ListofForbidTags, SetofForbidTags), intersection(SetofForbidTags, InterForbidtags, NewInterForbidtags), delCrazyRight(Q,NewInterForbidtags).
Partager