projog

3.102. append(ListOfLists, List) - concatenates a list of lists.

The append(ListOfLists, List) goal succeeds if the concatenation of lists contained in ListOfLists matches the list List.

Examples

?- append([], []).

yes

?- append([[]], []).

yes

?- append([[a]], [a]).

yes

?- append([[a,b,c],[d,e,f,g,h]], [a,b,c,d,e,f,g,h]).

yes

?- append([[a,b,c],[d,e,f,g,h]], [a,b,c,d,e,f,g,x]).

no

?- append([[a,b,c],[[d,e,f],x,y,z],[1,2,3],[]],X).
X = [a,b,c,[d,e,f],x,y,z,1,2,3]

yes

?- append([[a,b,c],[[d,e,f],x,y,z],[1,2,3],[]],[a,b,c,[d,e,f],x|X]).
X = [y,z,1,2,3]

yes

?- append(a, X).

Expected LIST but got: ATOM with value: a

?- append([a], X).

Expected list but got: ATOM with value: a

Note: unlike SWI Prolog, the first argument cannot be a partial list.

?- append([[a,b|X],[c,d]], Y).

Expected list but got: LIST with value: .(a, .(b, X))

?- append([[a,b],[c,d|X]], Y).

Expected list but got: LIST with value: .(c, .(d, X))

?- append([[a,b|X],[e,x|Y]], [a,b,c,d,e,x,y,z]).

Expected list but got: LIST with value: .(a, .(b, X))

?- append([[a,b|X],[e,x|Y]], [a,b,c,d,e,x,y|Z]).

Expected list but got: LIST with value: .(a, .(b, X))