I use the following idiom for string insertion.  It works reasonably
well when the integer width is small, 1 or 2 bytes.

But first, let's change the problem slightly get rid of the "e", then
insert "www" after the "l" in "alx".  This solution is for origin 1.

      a←'alx'
      b←'www'
      (a,b)[⍋(⍳⍴a),(⍴b)⍴2]

⍳⍴a is 1 2 3
2 is the position of the "l".  The "www" will be inserted after this position.
(⍴b)⍴2 is 2 2 2
⍋(⍳⍴a),(⍴b)⍴2 is 1 2 4 5 6 3

This technique works very well with multiple insertions.

Reply via email to