domains
x = integer
l = integer*
predicates
reverse(l,l)
concatenate(l,l,l)
clauses
concatenate([],List,List).
concatenate([X|List1],List2,[X|List3]) :-
concatenate(List1,List2,List3).
reverse([],[]).
reverse([Head|Tail],List) :-
reverse(Tail,List1),
concatenate(List1,[Head],List).
Output :
Goal: reverse([2,1,3,4],List)
List=[4,3,1,2]
1 Solution