IMHO, 'AA' does occur twice in 'AAA', as E. indicates.
But the result of 'AA' removeStr 'AAA' is always 'A'.


R.E. Boss


-----Original Message-----
From: Programming <[email protected]> On Behalf Of Devon 
McCormick
Sent: maandag 31 augustus 2020 02:56
To: J-programming forum <[email protected]>
Subject: [Jprogramming] Too unintuitive?

Hi -

I just wrote a string removal verb:

NB.* removeStr: remove string x from string y
removeStr=: 4 : 0
   wh=. I. whb=. x E. y
   rmb=. -. (1) (~.;(<i.#x)+&.>wh)}whb
   rmb#y
NB.EG 'H n brn c?' -: 'ow' removeStr 'How now brown cow?'
NB.EG 'abcdef' -: 'AA' removeStr 'abcAAAdefAAA'  NB. May be non-intuitive
)

Note the second example in the comment on the final line - since 'AA'
occurs twice in 'AAA', both are removed, thus removing the triplet.  It seems 
an unlikely case but is this behavior too confusing?

Does anyone have an alternate version of this?

Thanks,

Devon
-- 

Devon McCormick, CFA

Quantitative Consultant
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to