title: Prolog Recursion through Set of
body: <p>I'm trying to work on this Prolog rule you pass in an input of a list of movies and it returns a list of a star that are involved in that particular movie.</p>
  
  <p><strong>Predicate:</strong></p>
  
  <pre><code>starsin(captain_america,chris_evan).
  starsin(avengers,chris_evan).
  starsin(ant_man,chris_evan).
  starsin(captain_marvel,chris_evan).
  starsin(iron_man,chris_evan).
  starsin(avengers,tom_holland).
  starsin(captain_marvel,tom_holland).
  starsin(captain_america,tom_holland).
  starsin(iron_man,robert).
  starsin(avengers,robert).
  starsin(captain_america,robert).
  </code></pre>
  
  <p>I tried to use set of rule but somehow I cant figure out a way to use it recursively:</p>
  
  <pre><code>link([Head],Set) :-
     setof(Star1,starsin(Head,Star1),Set).
  </code></pre>
  
  <p><strong>Input and Output:</strong></p>
  
  <pre><code>link([ironman],Set).
  Set=[chris_evan,robert]
  </code></pre>
  
  <p>Somehow I want to pass in more than one element in the list but I need to use recursive. </p>
  
  <p>Is there anyway I could do it?</p>