title: Prefix in Prolog
body: <p>I'm new in Prolog.
  I have a problem about predicate prefix but a little bit different.</p>
  
  <p>I want to get a prefix of a list but until an element
  The list can have repeat elements.</p>
  
  <p>An example: </p>
  
  <pre><code>prefix(Element, List, Prefix)
  prefix(c, [a,b,c,d,e,f], [a, b])
  </code></pre>
  
  <p>The element is not included.</p>
  
  <p>What I have so far is this</p>
  
  <pre><code>prefix(X, [X|T], []).
  prefix(X, [Y|T], [Y|Z]):-
      prefix(X, T, Z).
  </code></pre>
  
  <p>But it does not work.</p>
  
  <pre><code>L = [a,b,c] ? prefix(b, L, Prefix).
  
  no
  ?- 
  </code></pre>
  
  <p>Thanks</p>