% our traditional list concatenation:
app([],L,L).
app([E|R],L,[E|RL]) :- app(R,L,RL).

% the classical quadratic list reverse:
rev([],[]).
rev([E|R],L) :- rev(R,UR), app(UR,[E],L).


% difference list concatenation (in constant time!):
append_dl(L-M, M-N, L-N).

% list reverse with difference lists:
%rev_dl([]   ,L-L).
%rev_dl([E|R],L-M) :- rev_dl(R,UR-T), append_dl(UR-T, [E|N]-N, L-M).

%revf(L,R) :- rev_dl(L,R-[]).

rev_dl([]   ,L,L).
rev_dl([E|R],L,M) :- rev_dl(R,L,[E|M]).

revf(L,R) :- rev_dl(L,R,[]).
