Split a list at the first occurrence of an element
<p>I was wondering if there is a function that lets me split a list at the first occurrence of an element, excluding that element. Basically, suppose:</p>

<pre><code>listT= [1,3,2,5,6,3,2,6]
</code></pre>

<p>then I want to define (or not, if it already exists), a function splitAtFirst so that</p>

<pre><code>splitAtFirst 2 listT = [[1,3],[5,6,3,2,6]]
</code></pre>

<p>my attempt so far looks like this:</p>

<pre><code>splitAtfirst::(Eq a)=&gt; a-&gt;[a]-&gt;[[a]]
splitAtfirst _ []=[]
splitAtfirst a (x:xs) 
   |a==x        = [xs]
   |otherwise   = [x]: splitAtfirst a (xs) 
</code></pre>

<p>However, I get</p>

<pre><code>&gt;splitAtfirst 2 [1,3,2,5,6,3,2,6]
&gt;[[1],[3],[5,6,3,2,6]]
</code></pre>

<p>I know why the problem happens, but so far I haven't been able to find a good solution</p>

<p>I appreciate any help!</p>

<p>Edit: this is an auxiliary function that only will be called after checking that elem is in the list, so dealing with the case when it does not exist it's not really necessary. I appreciate your help </p>