I have a list of strings:
lis = {{"a","b","x"},{"d","e","y"},{"a","b","z"},{"d","c","x"},{"a","b","w"}}
I would like to use StringJoin on the last elements where initial elements are the same to obtain:
res = {{"a","b","xzw"},{"d","e","y"},{"d","c","x"}}
Doing:
lis = SortBy[lis, {#[[1]]} &]
SequenceCases[lis, {{a_, b_, c_}, {a_, b_, d_}} :> {a, b, StringJoin[c, d]}]
only gives:
{{"a", "b", "wx"}}
Thanks for any suggestions.
ToCharacterCode
), then I could also image faster methods. $\endgroup$ – Henrik Schumacher Sep 27 '18 at 19:43