Prolog: delete all spaces in list
<p>I have list of lists like this:</p>

<pre><code>[[q, ,w, ,e, ,r, ,t, ,z],[a, ,s, ,d, ,f, ,g, ,h],[y, ,x, ,c, ,v, ,b, ,n]]
</code></pre>

<p>and I need to delete all spaces except in last list.
So I want:</p>

<pre><code>[[q,w,e,r,t,z],[a,s,d,f,g,h],[y, ,x, ,c, ,v, ,b, ,n]]
</code></pre>

<p>I tried:</p>

<pre><code>deleteAll([_|[]],[]).
deleteAll([Head|Tail],L) :-
  deleteAll(Tail,_),
  subtract(Head,[ ],L).
</code></pre>

<p>But it doesnt work. I'm getting onlny:</p>

<pre><code>[q, ,w, ,e, ,r, ,t, ,z]
</code></pre>

<p>So it seems that even <em>subtract</em>  didnt match the [ ] as space.
How can I achieve this?</p>