title: Splitting a list in half
body: <p>trying to write code that splits a list in half for even numbers of elements, eg. <code>split([1,2,3,4],A,B)</code> would give <code>A = [1,2]</code> and <code>B = [3,4]</code>.</p>
  
  <p>And behave like Java <code>list.length()/2</code> would for odd numbers of elements, so <code>split([1,2,3,4,5],A,B)</code> would give <code>A = [1,2]</code> and <code>B = [3,4,5]</code>.</p>
  
  <p>The closest I can get is something like this, but this isn't quite right, and  only works for even numbers.</p>
  
  <pre><code>split(L, A, B) :-
    append(A, B, L),
    length(A, N),
    length(B, N).
  </code></pre>