:- module(_, [nreverse/2], [assertions, regtypes, nativeprops]).

:- entry nreverse(Xs, Ys) : list * term.
:- pred nreverse(Xs, Ys) : list * term.

nreverse(Xs, Ys):-
	nreverse_(Xs, Ys).

:- pred nreverse_(Xs, Ys) : list * term => list * list.

nreverse_([], []).
nreverse_([X|Xs], Ys):-
	nreverse_(Xs, Ys0),
	append(Ys0, [X], Ys).

:- pred append(Xs, Ys, Zs) : list * list * term => list * list * list.

append([], Ys, Ys).
append([X|Xs], Ys, [X|Zs]) :-
	append(Xs, Ys, Zs).
