Do you mean taking a set of objects, eg

   o=:7 8 1

and applying a gerund of verbs eg

   g=: +`|.`3:

to it? Like

   g `:0 o

7 8 1
1 8 7
3 0 0

?

greg
~krsnadas.org

--

from:    Thomas Costigliola <[email protected]>
to:      J Programming Forum <[email protected]>
date:    23 January 2013 12:51
subject:         Re: [Jprogramming] applying >1 gerunds to a set of items

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.
--

from:    Raul Miller <[email protected]>
to:      [email protected]
date:    23 January 2013 11:51
subject:         Re: [Jprogramming] applying >1 gerunds to a set of items

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

--

from:    Marshall Lochbaum <[email protected]>
to:      [email protected]
date:    23 January 2013 11:43
subject:         Re: [Jprogramming] applying >1 gerunds to a set of items

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

--

from:    Aai <[email protected]>
to:      [email protected]
date:    23 January 2013 10:41
subject:         Re: [Jprogramming] applying >1 gerunds to a set of items

Perhaps a mapping like

((%:`*:`:0) ; (>:`<:`+:`:0)) [ 1 2 3
+-----------------------+
¦1 1.41421 1.73205¦2 3 4¦
¦1 4 9¦0 1 2¦
¦ ¦2 4 6¦
+-----------------------+

--

from:    Raul Miller <[email protected]>
to:      [email protected]
date:    23 January 2013 10:27
subject:         Re: [Jprogramming] applying >1 gerunds to a set of items

That's what already happens, but if you want to match the gerund to
the item, I'd do something like this:

   grea=: 4 :'x`:6 y'"0 _1
   1:`2:`3: grea 7 8 9

Raul

--

from:    bob therriault <[email protected]>
to:      [email protected]
date:    23 January 2013 10:01
subject:         Re: [Jprogramming] applying >1 gerunds to a set of items

Do you mean matching the gerunds to the corresponding items?

My initial take would be to apply m `:0 to atoms using rank "0 and
then take the diagonal of the result.

   (<0 1)&|:@:(+`*`|`:0"0)  2 3 4
2 1 4

Cheers, bob

--

from:    R.E. Boss <[email protected]>
to:      Programming forum <[email protected]>
date:    23 January 2013 09:29
subject:         [Jprogramming] applying >1 gerunds to a set of items

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

Reply via email to