title: Deep Reverse in PROLOG - Lists
body: <p>Hey I'm trying to create a predicate for the generating of a deep reverse on nested Lists in PROLOG.</p>
  
  <p>Currently I got this predicate</p>
  
  <pre><code>reverse(L,A) :- rev(L,[], A).
  rev([],A,A).
  rev([H|L],R,A) :- rev(L,[H|R],A).
  </code></pre>
  
  <p>The result looks like this:</p>
  
  <pre><code>reverse([1,2,3],A).
  A = [3, 2, 1].
  
  reverse([[0,1],2,3],A).
  A = [3, 2, [0, 1]].
  </code></pre>
  
  <p>The problem is, that the inner List is not reversed. It should look like this:</p>
  
  <pre><code>reverse([[0,1],2,3],A).
  A = [3, 2, [1, 0]].
  
  reverse([1,2,[3,4,5,[6,7],8],[9,10],11,12],A).
  A = [12,11,[10,9],[8,[7,6],5,4,3],2,1].
  </code></pre>
  
  <p>Thanks for any help.</p>