I know how to do it for 2 lists:
append([],L,L). append([H|T],L,[H|R]):-append(T,L,R).
but how to do it for 3? Without using the append for
Hope I understood the question (and I don't think the following is more efficient than the other solutions here), but did you mean something like this?
append([],[],L,L). append([],[H|T],L,[H|R]) :- append([],T,L,R). append([H|T],L0,L1,[H|R]) :- append(T,L0,L1,R).