Hi Michal,
Yes this is the expected behaviour. From the dictionary page for
rank<http://www.jsoftware.com/help/dictionary/d600v.htm>(u"n) :
The verb u"n applies u to each cell as specified by the rank n .
u refers to a verb and the verb includes its inbuilt verb rank.
So rank (") controls the size of the chunks of arguments that are fed to
the verb. The underlying rank of primitive verbs is not changed.
You can check the rank of a verb using: <verb> b. 0
* b. 0
0 0 0
*/ b. 0
_ _ _
i. b. 0
1 _ _
Explicitly defined verbs and verbs that include trains have default rank of
_ _ _ , but that can be altered as part of the verb definition.
times=: 4 : 0
x * y
)
times b. 0
_ _ _
times1=: 4 : 0"1 2
x * y
)
times1 b. 0
2 1 2
times2=: [ * ]
times2 b. 0
_ _ _
times3=: ([ * ])"1 2
times3 b. 0
2 1 2
Either way, they too won't be changed by additional rank conjunctions. IOW
you can't increase the chunk size of arguments that will be fed to a
defined verb above its verb rank, but you can restrict them.
On Mon, Jun 17, 2013 at 6:59 AM, Michal D. <[email protected]>wrote:
> Hi All,
>
> Here's an interesting behaviour I came across while trying to implement a J
> interpreter - the behaviour of nested ranks. It turns out that using "
> actually does not modify the rank of the underlying verb but adds another
> wrapper in how it is applied.
>
> Note that (1) and (2) below produce different results.
>
> box2 provides an easier way to visualize what arguments a verb is applied
> to.
>
> Mike
>
> ---
>
> ] y=:2 2 $ 0 1 100 0
> 0 1
> 100 0
> ] z =: 2 2 2 $ 1+i. 100
> 1 2
> 3 4
>
> 5 6
> 7 8
> y *"1 2 z NB. (1)
> 0 0
> 3 4
>
> 500 600
> 0 0
> y (*"1 1)"1 2 z NB. (2)
> 0 2
> 0 4
>
> 500 0
> 700 0
> box2=: (<@:[),(<@:])
> y box2"1 2 z
> +-----+---+
> |0 1 |1 2|
> | |3 4|
> +-----+---+
> |100 0|5 6|
> | |7 8|
> +-----+---+
> y (box2"1 1)"1 2 z
> +-----+---+
> |0 1 |1 2|
> +-----+---+
> |0 1 |3 4|
> +-----+---+
>
> +-----+---+
> |100 0|5 6|
> +-----+---+
> |100 0|7 8|
> +-----+---+
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm