Append Lists

The 'append' rule (program) can be used to append or join together two lists, e.g., (1,2)++(3)→(1,2,3) try the query: ?append(c(1,c(2,nil)), c(3,nil), Ans). There may be multiple solutions.
'append' can also be run backwards to find what two lists 'X' and 'Y', when appended, yield a specified list, (1,2,3) say. Try the query: ?append(X, Y, c(1,c(2,c(3,nil)))).




There are more Prolog examples here.