I just wanted to be sure the error wasn't because of a bug. Thanks for suggesting rplc. I was using it before I wrote my own. I did it more to learn J than for performance, but your comment got me to writing some timing tests. It was nice to learn how much faster the loop free code is. Finding loop free code is a game I've been playing since I learned APL in 1969, but it definitely isn't always faster. I hadn't timed my approach before I included code from nosindx, so I can't be sure which parts matter.
The two approaches are much closer in performance when there are multiple transformations. I had a contrived example that made several changes intended to get back to the original. It took me a while to realize that rplc looks for all the targets in the original before doing the replacements. That made rplc appear faster until I realized it wasn't applying all the changes and not getting the result I was expecting. So I've eliminated tests where the two have different objectives. Paul On Sat, Jun 20, 2020, 6:25 PM Raul Miller <[email protected]> wrote: > This is a consequence of the changed meaning of x m}y for rank 2 m. > > The fix is to ravel each of the m arguments for } in that definition, > > For example: > case. 1 do. (0 (,j+/(#q)+i.d)}1$~#x) # q (,k)}x > > That said, note also: > 'this a is a a test' rplc ' a ';'' > thisisa test > > -- > Raul > > On Sat, Jun 20, 2020 at 6:52 PM Paul Jackson <[email protected]> wrote: > > > > I just thought to look for a published solution to non looping handling > of > > overlaps returned by E. in this link: > > > > https://code.jsoftware.com/wiki/Essays/Substring_Replacement > > > > While nosindx works and gives me what I really wanted, the calling verb > > replace fails for all three parts of the case statement. > > > > 'this a is a a test' replace ' a ';'' > > > > |index error: replace > > > > | (0(j+/(#q)+i.d)}1$~#x)#q k}x > > > > I had just updated to the latest release before I began testing. > > > > JVERSION > > > > Engine: j901/j64/android > > > > Release-f: commercial/2020-06-12T10:01:40 > > > > Library: 9.01.24 > > > > J Android: 1.4.09/9/28 > > > > Platform: Android 64 (arm64-v8a) > > > > Installer: unknown > > > > InstallPath: > /storage/emulated/0/Android/data/com.jsoftware.j.android/files > > > > Contact: www.jsoftware.com > > > > I've confirmed it works in Windows, which I seldom update. So I'm not > sure > > this is release or platform related. > > > > Engine: j805/j64/windows > > > > Beta-14: commercial/2016-10-28T10:54:53 > > > > Library: 8.05.07 > > > > Platform: Win 64 > > > > Installer: J805 install > > > > InstallPath: c:/users/paul/documents/j64-805 > > > > Contact: www.jsoftware.com > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
