Prolog - 允许列表L iff #L> n在setof / 3中

时间:2016-11-12 02:05:25

标签: prolog-setof

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([_,_|_]).

但我怎么用呢?

谢谢。

0 个答案:

没有答案