likes(russel, wittgenstein).
likes(whitehead, wittgenstein).
likes(godel, wittgenstein).
likes(hardy, ramanujan).
likes(littlewood, ramanujan).
at_least_three_fans :-
setof(X, Z^(fact(X, idol), fact(Z, idol)), admirers).
I'd like to have print only Z : Z = wittgenstein, i.e., I'd like to have only the idols that have 3 or more admirers. The output to the predicate above:
?- at_least_three_fans.
idol = wittgenstein,
admirers = [godel, russell, whitehead].
idol = ramanujan,
admirers = [littlewood, hardy].
The following occurred to me:
at_least_three([_,_|_]).
But how am I to use it?
Thank you.