domains
list=symbol*
predicates
rev(list)
findrev(list,list,list)
clauses
rev(L):-
findrev(L,[],List2),
write("\nReverse Of Given List : ",List2).
findrev([],List1,List1).
findrev([X|Tail],List1,List2):-
findrev(Tail,[X|List1],List2).
OUT PUT
=======
Goal: rev([a,b,c,d,e])
Reverse Of Given List : ["e","d","c","b","a"]
Yes
----------------------------------------------------------------------
Goal: rev([])
Reverse Of Given List : []
Yes
----------------------------------------------------------------------
Goal: rev([y,o,g,e,s,h,p,a,t,e,l])
Reverse Of Given List : ["l","e","t","a","p","h","s","e","g","o","y"]
Yes