title: Splitting a list at an specified element
body: <p>I've been trying to split a Prolog at a given element. I've come close but I can't get the left part of the list.</p>
  
  <pre><code>split(X,[Y|L]) :- split(X,[Y|L],[Y|K],M).
  split(_,[],[],[]).
  split(X,[Y|L],K,[Y|M]) :- X &lt; Y, split(X,L,K,M).
  split(X,[Y|L],[Y|K],M) :- X &gt;= Y, split(X,L,K,M).
  split(X,[Y|L],[Y|K],M) :- X = Y, write(Y), write(' '), write(L).
  </code></pre>
  
  <p>Input: </p>
  
  <pre><code>split(2,[1,2,3,4,5]).
  </code></pre>
  
  <p>Returns: </p>
  
  <pre><code>2 [3,4,5]
  </code></pre>
  
  <p>I want it to return </p>
  
  <pre><code>[1,2] [3,4,5].
  </code></pre>