In previous article we have seen how to append the list into another. In this article, we will see how to reverse a list. To identify a standard technique where we reverse a list by appending its head to the reverse of its tail. The goal succeeds if the result of reversing the order of the elements in list L is List M.
PROGRAM:
reverse([X|Y],Z,W):-REVERSE[Y,[X|Z],W]. reverse([],X,X).
OUTPUT: