% lastoflist2.pl: The only change from the original version is that the
% fact changed to a rule, a rule with an exclamation point as its body.
% This is a "cut".  What's being 'cut' is Prolog's normal search.  Instead
% of producing the element at the end of the list and asking if we'd like
% to continue the search for another answer that can't exist, the cut
% stops the backtracking.  I'll explain in more detail in class.
%
% The point:  We can, easily, tell Prolog to report the last list element
% and stop immediately, improving efficiency of the search.

lastoflist([OneElem],OneElem) :- !.
lastoflist([_|T],Rest) :- lastoflist(T,Rest).
