domains
x = integer
l = integer*
predicates
concatenate(l,l,l)
last(x,l)
clauses
concatenate([],List,List).
concatenate([X|List1],List2,[X|List3]) :-
concatenate(List1,List2,List3).
last(X,List) :-
concatenate(List,[X],List1),
write("The new list is ",List1),nl.
Output :
Goal: last(3,[2,1,6,3])
The new list is [2,1,6,3,3]
Yes