SubstitutedWord( w, from, to, by )
SubstitutedWord
returns a new word where the subword of the word w
that begins at position from and ends at position to is replaced by
the word by. from and to must be positive integers. Indexing is
done with origin 1.
In other words SubstitutedWord(w,from,to,by)
is the word
Subword(w,1,from-1) * by * Subword(w,to+1,LengthWord(w)
(see Subword).
gap> a := AbstractGenerator("a");; gap> b := AbstractGenerator("b");; gap> w := (a^2*b)^5*b^-1; a^2*b*a^2*b*a^2*b*a^2*b*a^2 gap> SubstitutedWord(w,5,8,b^-1); a^2*b*a^3*b*a^2
GAP 3.4.4