[ library(lists) | Reference Manual | Alphabetic Index ]
Succeeds if Reversed is the reversed list List.
- A List.
- List or variable.
The List is reversed and the resulting list is unified with Reverse.
The definition of this Prolog library predicate is:
reverse(List, Rev) :-
reverse(List, Rev, ).
reverse(, L, L).
reverse([H|T], L, SoFar) :-
reverse(T, L, [H|SoFar]).
This predicate does not perform any type testing functions.
Modes and Determinism
Fails if Reverse does not unify with the reversed version of List.
[eclipse]: reverse([1,2,3,4,5], X).
X = [5, 4, 3, 2, 1]
append / 3, member / 2