Re: [Bug-apl] West way to remove substrings?

2017-03-15 Thread enztec
something i had from a while back #! rmsubstr ∇rs←substr rmsubstr string ⍝ " " quotes required for all strings and substrings ⍝ test variables - names for ease in testing s1←string1←"abcdefghijkcdecef" s2←string2←"abcdefghijkcdecefa" s3←string3←"a"⍝ single element string ss1←substr1←"

Re: [Bug-apl] West way to remove substrings?

2017-03-14 Thread mwgamera
How about {⊃,/(¯1+↑⍴⍺)↓¨(~⍺⍷⍵)⊂⍵←⍺,⍵} It doesn't rely on ⎕IO setting. -k On 14 March 2017 at 15:20, Elias Mårtenson wrote: > In a discussion on the #lisp IRC channel recently, someone wanted to remove > a certain substring from a larger string. In Lisp, the solution is to simply > use cl-p

Re: [Bug-apl] West way to remove substrings?

2017-03-14 Thread Jay Foad
This is a bit simpler and fixes the empty result problem, and returns a non-enclosed result: RemoveSubstrings ← {⍵/⍨ ~⊃∨/ (-⍳⍴⍺) ∘.⌽ ⊂⍺⍷⍵} Like your solution this only works with ⎕IO←0. On 14 March 2017 at 14:20, Elias Mårtenson wrote: > In a discussion on the #lisp IRC channel recently, someo

[Bug-apl] West way to remove substrings?

2017-03-14 Thread Elias Mårtenson
In a discussion on the #lisp IRC channel recently, someone wanted to remove a certain substring from a larger string. In Lisp, the solution is to simply use cl-ppcre and remove by regex. But, I started thinking about how to do this in APL, and this is what I came up with: RemoveSubstrings ←