Prolog scheduling without pressing ';' every time

70 Views Asked by At

I have the following file with the predicate attends which symbolizes that every student attends a certain course (the first argument : Student_ID, the second argument : Course_ID).

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

I want to create a predicate-function that will be as follows:

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

Where W1 (Week1) will be a list with 3 courses ( e.g W1= [c216,c205,c902]) and E will be the number of courses that the student will be examined on.

The problem is that for every student there will be backtracking so i have to press ";". So for each student there is a different E. Instead what i want is to have all of these E values in one list without pressing ";" and then see how many E values are larger that 2 (>2).

0

There are 0 best solutions below