I use /. (Oblique-Key ) with a gerund for this since the obliques of rank 1
arrays are the items.
</. 1 2 3
┌─┬─┬─┐
│1│2│3│
└─┴─┴─┘
+:`*:`%/. 1 2 3
2
4
0.333333
BTW, I miss being able to do this
<@(+:`*:`%)/. 3 4 5 NB. Removed from language!
Using key, you can also apply the successive verbs in the gerunds to
successive groups.
See the vocab /. for more.
On Wed, Jan 23, 2013 at 2:51 PM, Raul Miller <[email protected]> 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