Bletch
This must be one of the worst-named predicates in the entire galaxy.
concatenate_lists/2 ... no? no. Must be named append/2 otherwise it's not codegolfy enough.
Tricks
How to remove an element from a list (which must contain it) using append/2 once, but at each possible position in turn. Best used with once/1
remove(Lin,Elem,Lout) :- append([Front,[Elem],Back],Lin), % decompose append([Front,Back],Lout). % recompose
Examples:
?- remove([a,b,c,d,xxx,f],xxx,Lout). Lout = [a, b, c, d, f] ; false. ?- remove([a,xxx,c,d,xxx,f],xxx,Lout). Lout = [a, c, d, xxx, f] ; Lout = [a, xxx, c, d, f] ; false. ?- remove([a,b,c,d,e,f],xxx,Lout). false. ?- remove([a,b,c,d,e,f],A,Lout). A = a, Lout = [b, c, d, e, f] ; A = b, Lout = [a, c, d, e, f] ; A = c, Lout = [a, b, d, e, f] ; A = d, Lout = [a, b, c, e, f] ; A = e, Lout = [a, b, c, d, f] ; A = f, Lout = [a, b, c, d, e] ; false.