How to find combination of list elements in Prolog?

"goktugerce ." <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CABmfHC3WeJM=tJcHFDvNKc7vGj23hmHPk9m8vvY_Z8UPhAk_5A@mail.gmail.com>
Hey guys, I'm new to prolog and kinda stuck in my homework. Here is my
sample knowledge base:

course(tk222-1, [m-3, m-4]).
course(tk222-2, [m-5, m-6]).
course(tk222-3, [t-3, t-4]).
course(tk222-4, [t-5, t-6]).
course(tk222-5, [m-3, m-4]).
course(cmpe230-1, [m-5, m-6, t-4]).
course(fa489-1, [w-3, w-4])

tk222, cmpe230 and fa489 are courses, tk222-1, tk222-2, tk222-3, tk222-4,
tk222-5, cmpe230-1 and fa489-1 are sections. Lists are the sections' course
days and hours, as you can understand. Two sections are conflicting if they
have class in the same day and same hour. And a plan is conflicting if it
has two or more conflicting sections. My problem is to write a predicate as
follows:

findNonConflictingPlans(+CourseList, -PlanList)
?- findNonConflictingPlans([fa489, tk222, cmpe230], PlanList).
PlanList = [[fa489-1, tk222-1, cmpe230-1], [fa489-1, tk222-4,
cmpe230-1], [fa489-1, tk222-5, cmpe230-1]]

How can I find combinations of courses in *CourseList* list and gather them
together in *PlanList*? I have written predicates to find:

   - If two sections are conflicting.
   - Non-conflicting pairs of Course1 and Course2.
   - If a section conflicts with any section in a SectionList.
   - All sections of a Course1 non-conflicting with any Course-Section pair
   in a SectionList.

Appreciate any help.

-- 
Göktuğ Erce Gürel
-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.