How is Elem working with a single element
<p>The problem is to pack consecutive duplicates of list elements into sublists.
I do not understand how <code>elem</code> is working with a single element here,</p>

<p>For Example,</p>

<pre><code>pack [1,1,2,2,3,4]
</code></pre>

<p>Then <code>x</code> will be 1 and <code>(head (pack xs))</code> will be 1.
How can: </p>

<pre><code>1 `elem`  1
</code></pre>

<p>work when <code>elem</code> is of type <code>a -&gt; [a] -&gt; Bool</code>? </p>

<p>Also, please explain the recursion.</p>

<pre><code>pack :: (Eq a) =&gt; [a] -&gt; [[a]]
pack [] = []
pack [x] = [[x]]
pack (x:xs) = if x `elem` (head (pack xs))
              then (x:(head (pack xs))):(tail (pack xs))
              else [x]:(pack xs)
</code></pre>