title: set union operation in Prolog : explanation
body: <pre><code>union([H|T],[],[H|T]).     
  union([],[H|T],[H|T]).    
  union([H|T], SET2, RESULT) :- member(H,SET2), union(T,SET2,RESULT).    
  union([H|T], SET2, [H|RESULT]) :- not(member(H,SET2)), union(T,SET2,RESULT).
  </code></pre>
  
  <hr>
  
  <p>I am able to understand that it is traversing the first list and adding based on whether the element is a member of 2nd list or not. I got the logic. However, the workflow is mysterious to me where it adds the elements of "second list" to the result once the first list is exhausted. </p>
  
  <p>Please could someone take a simple example like <code>union([1,2], [2,3], Result)</code>, and explain the workflow. </p>