我有事实:
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).
我需要为:
编写查询学生有多少科目学习?
哪个分支研究受试者pm和plc?
答案 0 :(得分:1)
aggregate_all(count, studies(cs, X), Count).
(请参阅Prolog count the number of times a predicate is true)
studies(X, pm), studies(X, plc).