head(X,[X|XS]). tail(XS,[X|XS]). concat([],Ys,Ys). concat([X|Xs], Ys, [X|Whatever]) :- concat(Xs,Ys,Whatever).