conc(?List1, ?List2, -ResultList)
conc(?List1, ?List2, +ResultList)

Concatenate List1 and List2 and unifiy the concatenated result with the parameter ResultList, i.e. this predicate appends List2 to List1 and matches the result with the last parameter.

The predicate conc/3 is very flexible, if the ResultList parameter is specified and only one of first two parameters is specified then it will produce the difference between the ResultList parameter and the other List. See the third example in the example table below.

This predicate is located in the file 'list.txt', use ensure_loaded/1 to include this file.

see also: del/3 largest_number/2 last/2 lengthlist/2 member/2 prefix/2 reverse/2 smallest_number/2 sublist/2 suffix/2 sum_list/2 sum_list_integer/2

Example
conc([a], [b], Result). succeeds and the Result variable is unified with the list [a, b]
conc( [a, b], [c, d], [a,b,c]). fails because the concatenated list is [a,b,c,d] and this list cannot be unified with the third parameter, which is [a,b,c]
conc( A, [c], [a,b,c]). succeeds and the first parameter is unified with the difference between the last two list parameters:
A=[a, b]
conc( A, B, [a,b,c]). Four solutions are produced, each possible combination of parameters that produce the list [a,b,c]:
A=[]
B=[a, b, c]

A=[a]
B=[b, c]

A=[a, b]
B=[c]

A=[a, b, c]
B=[]

 

 

info@trinc-prolog.com