Am 12.04.2016 um 13:18 schrieb Jay Foad: > 'foobartestfootest' replace 'foo' 'xy'
Hi,
there are some corner conditions ((1↓u),⍺ contains u, but ⍺ does not):
replace←{(⍴v)↓∊(⊂v),¨(↑⍴u)↓¨(+\u⍷a)⊂a←u,⍺⊣(u v)←⍵}
'foobartestfootest' replace 'foo' 'xy'
xybartestxytest
'foobartestfootest' replace 'ofo' 'xy'
xyobartestfootest
Fixes it:
replace←{((0=⍴z)/a),z←∊((e×⍴v)↑¨⊂v),¨((⍴u)×e←+/¨(1+p)⊂p)↓¨(1++\p←u⍷a)⊂a←⍺⊣(u
v)←⍵}
'foobartestfootest' replace 'ofo' 'xy'
foobartestfootest
Greetings,
HP
