0

我有以下带有谓词参加的文件,这表示每个学生都参加了某门课程(第一个参数:Student_ID,第二个参数:Course_ID)。

attends(476, c216).
attends(478, c216).
attends(484, c216).
attends(487, c216).
attends(491, c216).

我想创建一个谓词函数,如下所示:

function(W1,L,E):- 
    bagof(C,attends(Y,C), L1),intersect(L1,W1,L),length(L,E).

    %W1 : Week-1 (List: contains courses that will be exams on).
    %L : List of intersection between students courses and the ones that 
    %  will be exams on that week(W1). (It is returned only for
    %  debugging, i don't actually need this
    % E : INT : Number of courses the student will be examined on the 1st week

其中 W1 (Week1) 将是一个包含 3 门课程的列表(例如 W1= [c216,c205,c902]),E 将是学生将参加考试的课程数量。

问题是每个学生都会有回溯,所以我必须按“;”。因此,对于每个学生来说,都有一个不同的 E。相反,我想要的是将所有这些 E 值放在一个列表中,而无需按“;” 然后看看有多少个 E 值大于 2 (>2)。

4

0 回答 0