How to count base clauses in another module in Prolog

62 Views Asked by At

In list.pl there is:

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

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

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

There may be another friend relations and people in list.pl.

In popular.pl I have:

:- 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).

I want this:

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

But I get this:

ERROR: is/2: Arguments are not sufficiently instantiated

How can I solve this?

0

There are 0 best solutions below