title: How do you append an element to a list in place in Prolog?
body: <p>If I have a list in Prolog such as X = [1, 2, 3, 4], how do I add the element 5 to the end of the list to have X = [1, 2, 3, 4, 5]?  </p>
  
  <p>The append function needs two lists, ie append(A,B,C) to get A and B concatenated to the list C.  </p>
  
  <p>I can do this with a temporary list Y = [1, 2, 3, 4] and Z = [5], to then do an append(Y, Z, X), but I don't like having a temporary list.  </p>
  
  <p>The usual disclaimers apply here - this is not homework and I am just learning Prolog.</p>