title: how to compare last element of a list with last element of another list in prolog?
body: <p>I want to find rhyming couplets of a poem so I need to compare last syllables of two verses of the poem.</p>
  
  <pre><code>cmp([A|As], [B|Bs]) :- cmp(As, A, Bs, B).
  
  cmp(A, [B], B, [A]).
  cmp([_, A|As], X, [_, B|Bs], Y) :- cmp([A|As], X, [B|Bs], Y).
  </code></pre>
  
  <p>I need, for example, to check if "[They, put, me, in, the, oven, to, bake]" and "[Me, a, deprived, and, miserable, cake]" rhymes, so I suppose I should check if last elements of these two lists are the same.</p>
  
  <p>With this code i tried to compare first and last elements of my lists but it doesn't work neither.</p>