On Thu, Jul 15, 2010 at 7:11 AM, Mark Allen <[email protected]> wrote:
> m =: '(rev[0-9]*).*(rot[0-9]*)'
> (m;,1) |. rxapply 'rev3 rot5'
> 3ver rot5
> (m;,2) _2&|. rxapply 'rev3 rot5'
> rev3 t5ro
>
> Is there any way in which i can apply the two verbs at once in the same
> expression?

I am a bit confused by the design of rxapply.  The index
is required to be a rank 1 list but only the first element
of that list is used.  So, at its heart, it has a scalar
design.

You would probably be better off writing your own
replacement for rxapply using rxmatches, rxfrom
and rxmerge.

Personally, if I were doing this, I think I would do something
like:

require'regex'
rxapplies=:1 :0
:
  mat=.,/}."2 x rxmatches y
  r=.((#m)|i.}:$mat) m 1 :(':';'(x{m)`:6 y')&.> mat rxfrom y
  r mat rxmerge y
)

   M=: '(rev[0-9]*).*(rot[0-9]*)'
   M |.`(_2&|.) rxapplies 'rev3 rot5'

(You can use identity functions for placeholders
and if you need to deal with the entire match instead
of one of the sub-matches you can fall back on
rxapply.)

FYI,

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

Reply via email to