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).
我想只打印Z:Z = wittgenstein, ie ,我想只有 3或更多的偶像崇拜者。输出到上面的谓词:
?- at_least_three_fans.
idol = wittgenstein,
admirers = [godel, russell, whitehead].
idol = ramanujan,
admirers = [littlewood, hardy].
以下情况发生在我身上:
at_least_three([_,_|_]).
但我怎么用呢?
谢谢。