L = [a, b, c|_]. – an example of an incomplete list. how do I append two of these? How do I reverse an incomplete list? Can someone give me tips how to deal with these in general?
append([x|t],y,[x|r]):-append(t,y,r). This is how two lists are appended.
for instance
These patterns are of little utility.
As @Daniel Lyons suggests, you can as well use append/3
You can see the difference between those patterns: first directly binds X to B (1 inference), while append requires a number of inferences equal to first list length, to reach the tail before binding.
You can read more about incomplete data structures here. The most useful pattern is
difference lists, the base for dcg.