%% reverse/2 — naive reverse via append/3.
%% Quadratic — accumulates the reversed prefix one append per cons.
reverse([], []).
reverse([H|T], R) :- reverse(T, RT), append(RT, [H], R).

append([], L, L).
append([H|T], L, [H|R]) :- append(T, L, R).
