Selectively replace multiple instances of a character within a string: Difference between revisions
Selectively replace multiple instances of a character within a string (view source)
Revision as of 18:23, 3 June 2022
, 2 years ago→{{header|J}}
m (→{{header|J}}) |
m (→{{header|J}}) |
||
Line 125:
<tt>upd</tt> here takes four arguments -- two on the left (replacement characters, original character) and two on the right(index values for which instances to replace, and the original string).
However, here's a more compact approach (the first item in the left argument is the target, and the rest of the left argument explicitly provides values for every instance of that item in the right argument):
<lang J> chg=: {{ (}.x) (I.y={.x)} y}}
|