title: Split list in prolog, produce two separate lists
body: <p>The Question:</p>
  
  <blockquote>
    <p>Define a predicate split/4 which, when provided with a list L and integer N returns two lists, A and B, where A contains the items in L that are greater than or equal to N and B contains the items that are lower than N. </p>
  </blockquote>
  
  <p>Sample query with expected result:</p>
  
  <pre><code>?- split([1, 5, 2, 3, 4], 3, A, B).
  A = [5, 3, 4],
  B = [1, 2].
  </code></pre>
  
  <p>My code: </p>
  
  <pre><code>spit([], 0, [], []).
  split([I|Is], N, [A|As], [_B|Bs]):-
      I &gt;= N,
      A is I,
      split(Is, N, As, Bs).
  split([I|Is], N, [_A|As], [B|Bs]):-
      I &lt; N,
      B is I,
      split(Is, N, As, Bs).
  </code></pre>
  
  <p>Rather than producing <code>A</code> and <code>B</code> as required, my code simply returns <code>false</code>. I'm not sure why. </p>