title: Getting the head and tail of a list
body: <p>I know if I do:</p>
  
  <pre><code>[H|T] = [a,b,c,d].
  H = a,
  T = [b,c,d].
  </code></pre>
  
  <p>What I'm trying to do is get the head and tail of a list inside a rule. Is this possible? I'm setting up base cases for a recursive call but for now I'd be satisfied if it just returned L3 as a append of the first list head and the second list head. I'm just not sure how I can get the head and list.</p>
  
  <pre><code>compose([], L1, L1).
  compose(L2, [], L2).
  compose([], [], []).
  compose(L1, L2, L3) :-
          [H1|T1] = L1,
          [H2|T2] = L2,   
          append(H1, H2, L3).  
  </code></pre>
  
  <p>I've also tried doing below based on what I've seen online:</p>
  
  <pre><code>compose([], L1, L1).
  compose(L2, [], L2).
  compose([], [], []).
  compose([H1|T1], [H2|T2], L3) :-
          append(H1, H2, L3).     
  </code></pre>
  
  <p>but the trace fails on the Call to this predicate.In a successful case I would like it to do the following:</p>
  
  <pre><code>compose([a,b,c], [d,e,f], L).
  L = [a, d].
  </code></pre>
  
  <p>at the very least for now.</p>