[Jprogramming] how to understand the rank in an power example in JforC

Zheng, Xin (NIH) [C] zhengxin at mail.nih.gov
Tue Sep 20 05:05:37 HKT 2011


It's a very nice way to explore J! Thanks a lot for sharing your great experience.

Best regards,
Xin

-----Original Message-----
From: Raul Miller [mailto:rauldmiller at gmail.com] 
Sent: Monday, September 19, 2011 4:48 PM
To: Programming forum
Subject: Re: [Jprogramming] how to understand the rank in an power example in JforC

On Mon, Sep 19, 2011 at 3:18 PM, Zheng, Xin (NIH) [C]
<zhengxin at mail.nih.gov> wrote:
> Hello all,
>
> I cannot understand the following example in JforC.
>
> 1 0 0 1 0 >:@]^:["_1 (1 2 3 4 5)
> Output - 2 2 3 5 5
>
> For which verb is the rank? For '>:@]^:[' ?
> And in x u^:v y, when v is a list, what's the rule in applying the verb?
>
> Appreciate any hint in advance.

Your original sentence:

   1 0 0 1 0 >:@]^:["_1 (1 2 3 4 5)
2 2 3 5 5

Rank of the verb as a whole:

   1 0 0 1 0 <@(>:@]^:["_1) (1 2 3 4 5)
+---------+
|2 2 3 5 5|
+---------+

Rank of the verb decorated using "_1

   1 0 0 1 0 <@(>:@]^:[)"_1 (1 2 3 4 5)
+-+-+-+-+-+
|2|2|3|5|5|
+-+-+-+-+-+

Rank and the verb controlled by ^:[

   1 0 0 1 0 <@(>:@])"_1 (1 2 3 4 5)
+-+-+-+-+-+
|2|3|4|5|6|
+-+-+-+-+-+

Rank and the verb controlling ^:

   1 0 0 1 0 <@([)"_1 (1 2 3 4 5)
+-+-+-+-+-+
|1|0|0|1|0|
+-+-+-+-+-+

In general, you can investigate how a part of a complicated J verb
works by updating the verb to shed light on the aspect which interests
you, and testing the modified verb against representative data.

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


More information about the Programming mailing list