如何计算Prolog中另一个模块的基本子句

时间:2018-05-31 17:10:47

标签: prolog instantiation-error

在list.pl中有:

:- module(list, [people/1, friend/2]).

people([a, b, c, d, e]).

friend(a, c).
friend(b, c).
friend(c, d).
friend(c, e).

list.pl中可能还有另一个朋友关系和人。

在popular.pl中我有:

:- module(popular, [friendCount/2]).
:- [list].


sum(A, B, S) :- S is A+B.

aggregate_all(count, friend(X, Y), Count).

friendCount(Person, Count) :-
  aggregate_all(count, friend(Person, X), C1),
  aggregate_all(count, friend(X, Person), C2),
  sum(C1,C2,Count).

我想要这个:

?- friendCount(c, Count).
Count = 4.

但我明白了:

ERROR: is/2: Arguments are not sufficiently instantiated

我该如何解决这个问题?

0 个答案:

没有答案
相关问题