I am interested in performing a long concatenation of lists, using Prolog language. The objective is to define a predicate that gets an unknown number of lists, and concatenates them all into one list (that is given as the second argument to the predicate).
I know I should first understand how Prolog supports arguments with unbounded size, but I think the answer to that is using lists, for example: [a | [[b,c,d] | [[e,f,g] | [h,i,j,k]]]].
If so, I thought about writing the predicate somewhat like this:
l_conc([ ],[ ]).
l_conc([[ ]|Tail],L):-
l_conc(Tail,L).
l_conc([[Head|L1]|Tail],[Head|L2]):-
l_conc([L1|Tail],L2).
However, it only concatenates empty lists to one another. Please help me here (both regarding the arguments representation and the predicate itself) :-) Thanks!