You're right about the 3 : error--I make that mistake far too often.

However, you missed my statement afterward that apply should be used
with rank _1. The "0 _ on apply is not there for loop control, and I
know that normal `:0 will have the same results. It's just to clarify
how apply works, since I think `:0 is a little confusing.

apply without the "0 _ is a tiny bit faster for the given use case, and
a lot faster in an expression like ((1e6 $ +:`-:`%) apply 2) where many
verbs are applied to a single argument. It's extremely slow compared to
operations without gerunds in either case, so the moral is probably just
not to use apply for performance-sensitive work.

Marshall

On Wed, Jan 23, 2013 at 02:51:04PM -0500, Raul Miller wrote:
> This sounds sensible, but if you tested your code, you should notice two 
> things:
> 
> First, 3 :'x,y' gives a domain error or a value error (depending on
> context).  To fix this you have several options:
> 
> You can remove the x -- probably not what you want.
> 
> You can change the 3 to a 4 -- probably the simplest and best option
> for this case.
> 
> You can introduce the ':' line which separates the monadic from the
> dyadic definition in an explicit verb -- probably overkill, but like
> this: 3 :(':';x`:0 y')"0 _
> 
> That gets you something that runs.
> 
> But this should reveal a new issue:  the behavior of 3 :'x`:0 y'"0 _
> gives you the same kind of results that 3 :'x`:0 y' gives you.  The
> rank of the derived verb is different, but that's a subtle sort of
> thing.  There's also a variety of ways of treating this issue, but
> most of them involve reducing the right rank of the derived verb
> (probably using "0 or "0 _1, depending on exactly what you are trying
> to achieve).
> 
> I hope this helps,
> 
> -- 
> Raul
> 
> On Wed, Jan 23, 2013 at 2:43 PM, Marshall Lochbaum <[email protected]> 
> wrote:
> > I think you mean to apply each gerund to a corresponding item of the
> > argument? In any case, I would suggest just making an apply verb
> >
> > apply =: 3 : 'x`:0 y' "0 _
> >
> > and applying it with the appropriate rank (_1 by my interpretation).
> > Since you understand rank, this is a general solution to an entire class
> > of problems.
> >
> > Marshall
> >
> > On Wed, Jan 23, 2013 at 06:29:00PM +0100, R.E. Boss wrote:
> >> In  <http://www.jsoftware.com/help/dictionary/d612.htm> 
> >> http://www.jsoftware.com/help/dictionary/d612.htm (`: n) is explained, but
> >> how do I apply a set of gerunds to one set of items?
> >>
> >>
> >>
> >>
> >>
> >> R.E. Boss
> >>
> >> ----------------------------------------------------------------------
> >> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to