title: Why does these rules work? (finding last element in list in prolog)
body: <p>I am trying to understand the following set of rules, which supposed to find the last element in a list (for instance <code>my_list(X,[1,2,3])</code> gives <code>X=3</code>).</p>
  
  <pre><code>my_last(X,[X]).
  my_last(X, [_|L]) :- my_last(X, L).
  </code></pre>
  
  <p>I understand the first fact - X is the last element of a list if X is the only element in it, but how does the second rule work? this looks a bit strange to me as a prolog noob, I'd love to know if there's an intutive way to interprate it.
  T</p>