I am dong some gluing of strings together and I wanted an intercalate capability like many languagues offer, e.g. "join" in _javascript_ or implode() with PHP and I came up with this:
join([], _, []).
join([X], _, [X]).
join([X|Xs], With, [X, With|Acc]) :- glue( Xs, With, Acc).
The great news is that I figured it out first time and it seems to do what I need, I also have a flatten() predicate that will produce the final output string.
However... I am not sure I truly understand how I did it... if I explain my reasoning perhaps somebody can straighten me out?