title: Prolog - Recursive call
body: <p>I am having trouble with recursive searching of list and creation of list of lists from the result..</p>
  
  <p>The knowledge base contains team name, number of wins and zone they are in, all associated withe their team number. I am passing list of team numbers in <code>Teams</code> and I am searching for a matching pair with <code>findMinMax/3</code>. The result I need is...</p>
  
  <p>List of lists of paired teams (ex. <code>X = [[gonzaga, washington], [iowa, oklahoma], …]</code>)
  And 1 unmatched team (resulted from odd number of teams) or 0 (in case of even)</p>
  
  <p>I figured out everything else and can get up to the part <code>[gonzaga, washington]</code>, but failing at recursive portion...</p>
  
  <pre><code>findPair(Teams,[HL|TL],Rest) :-
      findMinMax(Teams,Min,Max),
      delete(Teams,Min,TeamsNoMin),
      delete(TeamsNoMin,Max,Rest),
      createPair(Min,Max,Pair), %Pair = "["Min_team","Max_team"]"
      append(HL,[Pair],TL),
      findPair(Rest,TL,[]).
  </code></pre>