在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
我该如何解决这个问题?