VILL- DEBANDI, AMTA, HOWRAH PIN-711410 Phone-9836357266
14. Write a Prolog program to implement reverse(List,ReversedList) that reverses lists.
reverse([],[]).
reverse([X|T],REV):-reverse(T,R),append(R,[X],REV).
OUTPUT:
reverse([1,2,2],X).
X = [2, 2, 1]
No comments:
Post a Comment