Guides/General FAQ/How do I define the rank of a verb I create?
< Guides | General FAQ
Jump to navigation
Jump to search
How do I define the rank of a user-defined verb?
If I write my own verb and want to specify a default rank, how do I do this?
Simply specify the rank in the definition, e.g. for an explicit function:
myVecVerb=: 3 : 0"1 NB. Apply to rank 1 objects (+/y)-<./y NB. Sum less smallest in row ) (i.3 3);myVecVerb i. 3 3 +-----+------+ |0 1 2|3 9 15| |3 4 5| | |6 7 8| | +-----+------+ myMatVerb=: 3 : 0"2 NB. Apply to rank 2 objects (+/y)-<./y NB. Sum less smallest in column. ) (i.3 3);myMatVerb i. 3 3 +-----+-------+ |0 1 2|9 11 13| |3 4 5| | |6 7 8| | +-----+-------+
Specify for a tacit definition in much the same way:
myVecVerb=: (+/-<./)"1 myMatVerb=: (+/-<./)"2
More info
See Also
General introduction to the concept of rank in J
"Studio" introduction to rank with examples
Rank Explanation of how negative values of rank work
FAQ/Atop Rank How to determine the rank of verb combinations