Dyalog's implementation is much more expressive than what I had proposed. There are technical reasons why we have no hope of replicating their functionality (in particular, GNU APL does not have support for namespaces).
Their function takes arguments and returns a function, which is a matcher function that can be reused, which is useful since you'd only compile the regexp once. Jürgen, how can I make a quad-function behave like below? It seems to be similar in behaviour to ⍤ and ⍣. * ('.at' ⎕R '\u0') 'The cat sat on the mat' * The CAT SAT on the MAT It can also accept a function, in which case the function is called for each match, to return a replacement string. Can you explain how to make a quad-function an operator? * ('\w+' ⎕R {⌽⍵.Match}) 'The cat sat on the mat'* ehT tac tas no eht tam As you can see, they leverage namespaces in order to pass a lot of different fields to the replace-function. If we want to do something similar, ⍵ would probably have to be the match string, and we'll have to live without the remaining fields. Regards, Elias On 23 September 2017 at 00:08, Juergen Sauermann < juergen.sauerm...@t-online.de> wrote: > Hi, > > I have not looked into Dyalogs implementation myself, but if they > have it then we should aim at being as compatible as it makes sense. > No problem if some of their capabilities are not supported (please avoid > going over the top in the GNU APL implementation) > > Unfortunately ⎕R is already occupied in GNU APL (inherited from IBM APL2), > so some other name(s) are needed. > > Before implementing too much in advance, it would be good to present the > intended syntax and semantics on bug-apl and solicit opinions. > > /// Jürgen > > > On 09/22/2017 04:59 PM, Elias Mårtenson wrote: > > I did not know this. I took a look at Dyalog's API and it's not possible > to implement it fully, as it relies on their object oriented features. > However, the basic functionality wouldn't be hard to replicate, if that is > something that is desired. > > Jürgen, what is your opinion on this? > > On 22 September 2017 at 20:21, Jay Foad <jay.f...@gmail.com> wrote: > >> FYI Dyalog has operators ⎕S (search) and ⎕R (replace) which are >> implemented with PCRE: >> >> ('[Aa]..'⎕S'&')'Dyalog APL' >> ┌───┬───┐ >> │alo│APL│ >> └───┴───┘ >> ('red' 'green'⎕R'green' 'blue')'red orange yellow green blue' >> green orange yellow blue blue >> >> http://help.dyalog.com/16.0/Content/Language/System%20Functions/r.htm >> >> Jay. >> > > >