Prolog program to find last item of the list.
domains namelist = symbol* predicates lastd(namelist,symbol) clauses lastd([Head],X):- X = Head. lastd([_|Tail],X):- lastd(Tail,X). Output : Goal: lastd([a,b,c,d],X) X=d 1 Solution