title: Test to see if all elements of list/variable are true
body: <p>I'm writing an adviser program that selects classes for students to take next semester.  One of the tasks is to check if the student has all of the prerequisites.  So far, I've got:</p>
  
  <pre><code>hasPrereqs(Student, Class) :-
      (prereq(Pre, Class) -&gt; 
          hasClass(Student, Pre);
      true).
  
  hasClass(Student, Class) :-
      (creditFor(Student, Class);
      currentlyTaking(Student, Class)).
  </code></pre>
  
  <p>prereqs are declared as such:</p>
  
  <pre><code>prereq(csc140, csc145).
  prereq(csc140, csc180).
  prereq(csc140, csc198).
  prereq([csc140, csc130], csc201).
  prereq(csc145, csc201).
  </code></pre>
  
  <p>This works for every possibility except when two classes are required for another class (as in <code>csc201</code>, where a student can take either csc140 AND csc130 OR just csc140).  I think lists are the way to go, but I can't figure out how to implement it.</p>
  
  <p>I've tried creating another <code>hasPrereqs</code> as follows:</p>
  
  <pre><code>hasPrereqs(Student, Class) :-
  forall(prereq(Pre, Class),
  (compound(Pre) -&gt; 
      hasClass(Student, Pre)).
  </code></pre>
  
  <p>This one won't work because <code>Pre</code> is a list, rather than a straight atom and thus:</p>
  
  <pre><code>creditFor(somekittens, csc130).
  creditFor(somekittens, csc140).
  /* Returns false, because I don't have credit for the list, just the two classes */
  creditFor(somekittens, [csc130, csc140]).
  </code></pre>
  
  <p>How can I set up the system so that classes requiring several other classes just work?</p>