%append []     ys = ys
%append (x:xs) ys = x : append xs ys

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

%rev []     = []
%rev (x:xs) = append (rev xs) [x]

rev([],[]).
rev([X|Xs],Ys) :- rev(Xs,Zs), app(Zs,[X],Ys). % Zs is an extra variable!!!
