%Examples:
%days([saturday,sunday,monday,tuesday,wednesday,thursday]).
%slots([1,2,3,4,5]).
%course_meetings(csen402,tutorial,t07,nehal,'tutorial for t07').
%course_meetings(comm401,lecture,all_group_4,dr_amr_talaat,'lecture 1')
%tutorialrooms([c6301,b4108,c2201,c2301,c2202,c2203]).
day_tut(Day,Slot,Place,Course,Group,Instructor,Descr):-
days(X),member(Day,X),
tutorialrooms(X1),member(Place,X1),
course_meetings(Course,tutorial,Group,Instructor,Descr),
slots(X2),member(Slot,X2),
assert(day(Day,Slot,tutorial,Place,Course,Group,Instructor,Descr)).
I would like to find a way to remove certain facts after asserting for example
every (day) fact has to have only one room for each day and slot
example: we can have day(sat,1,_,c6301,_,_,_,_)
and
day(sat,1,_,c6302,_,_,_,_)
but we can't have
another occurrence of day(sat,1,_,c6301,_,_,_,_)
.
If you simply want to remove redundant solutions of a Goal
– this is what you probably mean with removing repetitions – simply replace Goal
by setof(t,Goal,_)
. This works as long as there are only ground solutions for Goal
and as long as Goal
terminates universally. Thus, there is no need for any data base manipulation to remove redundant solutions.
?- member(X, [a,b,a,c]). X = a ; X = b ; X = a % redundant! ; X = c. ?- setof(t,member(X, [a,b,a,c]),_). X = a ; X = b ; X = c.