I was looking at the ranks of primitives and was wondering if there was a
particular justification for the rank of monadic i: (Steps) being 0. In fact, I
began this by looking at monadic #: (Antibase 2) and wondering why its rank was
_ . Both verbs seem to act on their arguments in similar ways, creating a
vector from a single atom input.
#: b. 0 NB. monadic - left dyadic - right dyadic ranks
_ 1 0
i: b. 0
0 _ _
#: 9
1 0 0 1
i: 9
_9 _8 _7 _6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6 7 8 9
It is only when you look at how they operate in higher dimensions that you see
the differences in the way padding is applied to results of different lengths.
#: 1 2 4 8
0 0 0 1
0 0 1 0
0 1 0 0
1 0 0 0
i: 1 2 4 8
_1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
_2 _1 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0
_4 _3 _2 _1 0 1 2 3 4 0 0 0 0 0 0 0 0
_8 _7 _6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6 7 8
The use of _ as the rank of monadic #: allows the result to know about its
neighbours and padding can be done in such a way as to retain the positional
meaning. Overriding to rank 0 provides an opportunity for a different result.
#:"_ [ 1 2 4 8
0 0 0 1
0 0 1 0
0 1 0 0
1 0 0 0
#:"0 [ 1 2 4 8
1 0 0 0
1 0 0 0
1 0 0 0
1 0 0 0
Using 0 as the rank of monadic i: takes away the ability to change the padding
because overriding to a rank of _ does not change the positioning.
i:"0 [ 1 2 4 8
_1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
_2 _1 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0
_4 _3 _2 _1 0 1 2 3 4 0 0 0 0 0 0 0 0
_8 _7 _6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6 7 8
i:"_ [ 1 2 4 8
_1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
_2 _1 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0
_4 _3 _2 _1 0 1 2 3 4 0 0 0 0 0 0 0 0
_8 _7 _6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6 7 8
Changing the rank of monadic i: would not be a priority for me, as it may break
existing scripts and I don't see a large gain except for consistency, but are
there other reasons for this that I may have missed? Also my anthropomorphized
view of how the verbs work may be flawed and I would welcome corrections to my
understanding.
Cheers, bob
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm