Don't double up


I have two text entries.

Let’s call them Ding and Dong.Ding is text that varies. Dong is text that varies.Oh Good so that works.

Through the magic of science and Cthulhu [size=1]Ph’nglui mglw’nafh C’thulhu R’lyeh wgah’nagl fhtagn[/size] I have been able to designate text to both Ding and Dong [size=1]and their third cousin, Jessebell[/size] however, they will be matched together. [code]DingDong is text that varies.

When play begins:
now DingDong is the substituted form of “[Ding][Dong]”;[/code]So far so good, right?

Well, sometimes Ding ends with the same letter that Dong begins with, which completely ruins the vibe of the thing.

Is there a way to check for last letters and first letters of text entries and compare to see if they’re the same, and if they are, to delete either of them, or alter them?

So instead of “DOG + GOAT = DOGGOAT” I would want (because I’m weird) “DOGOAT” instead of doubling up on G’s.

Bonus points if I can check to see if they double up and in that case change the G in GOAT with a B, to create a DOGBOAT.

Is there a way this can be done in GLULX?

You’re getting into the manipulating text strings layer of inform, which is in the documentation. So I know the answer is yes, but I personally haven’t gotten that advanced yet.

I have no doubt that it’s in the manual but I can’t find it or I’m looking wrong. In related news, I’m really good at not finding things. Even obvious things. [size=1]Because I’m dangerously r-… You know how this goes.[/size]

[code]To say compression of (A - a text) and (B - a text):
let N be the number of characters in A;
let x be character number N in A;
let y be character number 1 in B;
if x is y, replace character number N in A with “”;
say “[A][B]”.

When play begins:
now DingDong is “[compression of Ding and Dong]”.[/code]

Freakin[’] SWEET thanks!