title: how to set value of an arg in Prolog?
body: <p>I have an assignment question like so:</p>
  
  <pre><code>Write a program to find the last element of a list. e.g.
  ?- last(X, [how, are, you]).
  X = you
  Yes
  </code></pre>
  
  <p>I'm currently finding the last element like this:</p>
  
  <pre><code>last([Y]) :-
      write('Last element ==&gt; '),write(Y).
  last([Y|Tail]):-
      last(Tail).
  </code></pre>
  
  <p>And it works.  My question is, how do I change it to accept and set the addition X parameter and set it correctly?</p>
  
  <p>I tried this, but it's not working ...</p>
  
  <pre><code>last(X, [Y]) :-
      X is Y.
  
  last(X, [Y|Tail]):-
      last(X, Tail).
  </code></pre>