我有一个关于电影的知识库。我的演员和演员谓词如下所示:
% actor(M,A,R) -- actor A played role R in movie M
% actress(M,A,R) -- actress A played role R in movie M
我试图在我的知识库中计算不同的演员。我只想写:
count(Nr):-
setof(Name,actor(Movie,Name,Role),List1),
setof(Name,actress(Movie,Name,Role),List2),
length(List1,Nr1),
length(List2,Nr2),
Nr is Nr1+Nr2.
它不起作用,但它确实如此:
count(Nr):-
setof(Name,(Movie^Role^actor(Movie,Name,Role)),List1),
setof(Name,(Movie^Role^actress(Movie,Name,Role)),List2),
length(List1,Nr1),
length(List2,Nr2),
Nr is Nr1+Nr2.
那么那个“^”是什么意思呢?
编辑:看起来每部电影和每个角色只选择一次。但我仍然不确定。