How to remove elements of a list?
<p>I have implemented a function which deleting elements of a list one by one:</p>
<pre><code>remove(_,[])-&gt;
  [];
remove(Elem, L)-&gt;
  Rest = lists:delete(Elem,L),
  remove(Elem,Rest).
</code></pre>
<p>But it hangs when I tried with this example:</p>
<pre><code>L = [1,2,3,4].
remove(hd(L), [L]).
</code></pre>
<p>What is wrong with it? Or is there a better way to delete elements in the list one by one starting from the first element of a list.</p>