title: Prolog: reverse list (sublists included)
body: <p>I have written the simple code to reverse a typical integer list:</p>
  
  <pre><code>reverse([], []).
  reverse([X], [X]).
  reverse([X|Y], A) :- reverse(Y, Z), append(Z, [X], A).
  
  ? reverse([1, 2, 3], X)
  X = [3, 2, 1].
  </code></pre>
  
  <p>However, I am pretty lost, as I am new to prolog, how to reverse a list that has other sublists within it, such as:</p>
  
  <pre><code>? reverse([1, [2, 3], [1, [3, [2, 4, 5], 1], 2], 5], X).
  X = [5, [2, [1, [5, 4, 2], 3], 1], [3, 2], 1].
  </code></pre>
  
  <p>etc.
  Any help is appreciated, thanks!</p>