Prolog事实和查询

时间:2013-11-03 11:47:58

标签: prolog

我有事实:

studies(it, da).      // IT branch studies the module DA
studies(it, pm).
studies(ie, pm).
studies(it, plc).
studies(it, se).
studies(cs, plc).
studies(cs, da).
studies(cs, se).

我需要为:

编写查询
  1. 学生有多少科目学习?

  2. 哪个分支研究受试者pm和plc?

1 个答案:

答案 0 :(得分:1)

  1. aggregate_all(count, studies(cs, X), Count).(请参阅Prolog count the number of times a predicate is true

  2. studies(X, pm), studies(X, plc).