It is possible to do list processing in Prolog.
The append predicate joins two lists together.
The function c can stand for the list constructor.
The result of appending nil and a list B is just B.
The result of appending c(H,T) and B
is c(H,TB) where TB is the result of appending T and B.
c(H, T) + B
------
= c(H, T+B )
--- Appending to a non-null List. ---
The result of appending the lists c(1,c(2,nil)) and c(3,c(4,nil))
is c(1,c(2,c(3,c(4,nil)))).
Note that most Prolog systems provide a nicer syntax for lists,
eg. [1,2,3,4].