Prolog在结构中查找重复项会导致存在错误

时间:2017-12-16 00:46:24

标签: prolog

当我调用我的规则shareActors时,我遇到了一个存在错误,如果两个电影有相同的actor,那么它应该是真的。提前谢谢!

movie(year(2003), title([pirates,of,the,carribean]), cast([actor(jonny, depp), actor(keira, knightley), actor(orlando, bloom)])).
movie(year(2014), title([guardians, of, the, galaxy]), cast([actor(chris, pratt), actor(karen,gillan) ])).                       
movie(year(1988), title([die,hard]), cast([actor(bruce, willis)])).                                                              
movie(year(2001), title([lord,of,the,rings]), cast([actor(orlando, bloom), actor(sean, bean)])).                                 
movie(year(2016), title([xmen, apocalypse]), cast([actor(jennifer,lawrence), actor(james, mcavoy)])).                            
movie(year(2014), title([the,imitation,game]), cast([actor(benedict, cumberbatch), actor(keira, knightley)])).                   
movie(year(2012), title([the,hunger,games]), cast([actor(jennifer,lawrence)])).                                                  
movie(year(2016), title([deadpool]), cast([actor(ryan, reynolds)])).                                                             

shareActors:-                                                             
        movie(_,_,cast(X)),
        movie(_,_,cast(Y)),
        intersect(X,Y,Z),
        Z \= [].

0 个答案:

没有答案