Having list append implementation in Prolog -
append([],X,X). append([H|T1],X,[H|T2]) :- append(T1,X,T2). Which gives on -
append([a,b,c],[d,e,f],X). The output -
X = [a,b,c,d,e,f]. I Wonderwonder how does it work , I tried to trace function calling but I didn't understand how T2 , which is the tail of a list , can be has as tail of X which in append([a,b,c],[d,e,f],X) calling had not defined yet . Can you clear up this recursion for me ?