% Implement the predicate can_register(Student, Course),
% where can_register(S,C) is true iff S is a student who has
% passed or waived all of the prerequisites of course C.
% For example, the prereqs of csc529 are csc330 and csc350.
% Suppose nancy passed csc330 and csc350: she can register for 529.
% Suppose dilbert passed csc330 and waived csc350: he can register for 529.
% Suppose snoopy passed csc330 but has not taken or waived csc350: he
% cannot register for 529!
% Your program should use facts stored in these predicates:
% prereq(Course, CList), where Clist is a list of courses that are
% prequisites of Course
% passed(Std, Course), where Std is a student who passed Course
% waived(Std, Course), where Std is a student who waived Course.
% Facts to use with your test cases:
prereq(csc529, [csc330, csc350]).
passed(nancy, csc330).
passed(nancy, csc350).
passed(dilbert, csc330).
waived(dilbert, csc350).
passed(snoopy, csc330).
pass_each(Student,[]).
pass_each(Student,[x]):- passed(Student,X),!.
pass_each(Student,[X]):- waived(Student,X).
pass_each(Student,[H|T]):- pass_each(Student,T),passed(Student,H),!.
pass_each(Student,[H|T]):- pass_each(Student,T),Waived(Student,H).
can_register(Std,Crse):- prereq(Crse,PrereqList),pass_each(Std,PrereqList).