|
From: | Jay Foad |
Subject: | Re: [Bug-apl] West way to remove substrings? |
Date: | Tue, 14 Mar 2017 15:10:51 +0000 |
EliasRegards,Does anyone have a better solution?Is this a good way of solving the problem? I realise that I have a bug when the resulting string is empty: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 ← {,/ ⍵ ⊂⍨ ↑~∨/ (-⍳⍴⍺) °.⌽ ⊂⍺⍷⍵}
"foo" RemoveSubstrings "foo"
DOMAIN ERROR
λ1[1] λ←,/⍵⊂⍨↑∼∨/(-⍳⍴⍺)°.⌽⊂⍺⋸⍵
^ ^
[Prev in Thread] | Current Thread | [Next in Thread] |