title: Shuffle in prolog
body: <p>I'm trying to write a procedure in prolog where if L1 = [1,2,3] and L2 = [4,5,6] then L3 = [1,4,2,5,3,6]</p>
  
  <p>so <code>shuffle([1,2,3],[4,5,6],[1,4,2,5,3,6])</code></p>
  
  <p>I have this so far:</p>
  
  <pre><code>shuffle([X],[Y],[X,Y]).
  shuffle([X|Xs],[Y|Ys],_) :- shuffle(Xs,Ys,Z), shuffle(X,Y,Z).
  </code></pre>
  
  <p>This is my first attempt at writing prolog code so I'm still trying to wrap my head around the syntax, rules and everything.</p>
  
  <p>I understand the logic, I'm just not sure how to implement it so any help would be greatly appreciated!</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit:</strong> I've figured it out. Here's the solution if anyone's interested:</p>
  
  <pre><code>shuffle([X],[Y],[X,Y]).  
  shuffle([X|Xs],[Y|Ys],[Z1,Z2|Zs]) :- shuffle([X],[Y],[Z1,Z2]),shuffle(Xs,Ys,Zs).
  </code></pre>