Vocabulary/RankInfo

From J Wiki
Jump to navigation Jump to search

Rank Information within the Accessible Dictionary

Back to: Vocabulary

Not only nouns but verbs too have Rank.

Find the rank(s) of a given verb (including a primitive) using Verb Information b.0

   i. b.0     NB. for example, the ranks of: i.
1 _ _
   $. b.0     NB. for example, the ranks of: $.
_ _ _

WARNING: if a particular rank is inapplicable to this primitive (monad or dyad), b.0 returns 0 in the corresponding position

   {: b.0     NB. for example, the ranks of: {: (which is MONADIC ONLY)
_ 0 0


Rank 0 -- operates on individual atoms of y, producing a result of the same shape

This verb operates on atoms of y and produces a result with the same shape as y. - is an example of this type of verb:

   i. 2 3
0 1 2
3 4 5
   - i. 2 3
 0 _1 _2
_3 _4 _5

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied to each atom of v y individually. If you get surprising results, see here.

Applies to <. <: > >. >: + +: * *: - -. -: % %: ^ ^. | ! ? d. H. j. o. p: r. t. t:


Rank 0 -- operates on individual atoms of y, producing a result of higher rank

This verb operates on atoms of y. Each atom produces a list of length two; when all these results are collected, it gives an overall result whose shape has the shape of y with 2 appended. +. is an example of this type of verb:

   +. 3j4 5
3 4
5 0

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied to each list of v y individually. If you get surprising results, see here.

Applies to +. *.


Rank 0 -- operates on individual atoms of y, producing a result that may require fill

This verb operates on atoms of y. The results from the atoms, which may have varying shapes, are collected into the final result, adding framing fill if necessary. > is an example of this type of verb:

   > a =. <1 2
1 2
   > b =. <3 4 5
3 4 5
   ]c =. a,b
+---+-----+
|1 2|3 4 5|
+---+-----+
   >c
1 2 0
3 4 5

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to an atom of y, before fill is added. If you use this verb as the v in u@:v, u&:v, or u&.:v, u will be applied once to the entire filled result of v y. If you get surprising results, see here.

Applies to > q: i:


Rank 1 -- operates on lists of y, producing an atom for each one

This verb operates on the lists of y (i. e. subarrays of rank 1, also called 1-cells). If y has rank greater than one, it is construed as an array of lists. If y is an atom, it is converted to a list of length 1 before being processed.

Applying the verb to a list produces an atom; the results from applying the verb on each list of y are collected into the final result, which will have the same shape as y except that the last axis is removed. A. is an example of this type of verb:

   A. 0 1 2 3
0
   A. 1 0 3 2
7
   ]r =. 0 1 2 3,:1 0 3 2
0 1 2 3
1 0 3 2
   $r
2 4
   A. r
0 7

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a list of y. If you get surprising results, see here.

Applies to #. A.


Rank 1 -- operates on lists of y, producing a list for each one

This verb operates on the lists of y (i. e. subarrays of rank 1, also called 1-cells). If y has rank greater than one, it is construed as an array of lists. If y is an atom, it is converted to a list of length 1 before being processed.

Applying the verb to a list produces a list of fixed shape; the results from applying the verb on each list of y are collected into the final result, which will have the same shape as y except that the last axis will have the length of each individual result. p. is an example of this type of verb:

   p. 3 4 1
+-+-----+
|1|_3 _1|
+-+-----+
   $ p. 3 4 1
2
   ]r =. 2 3 $ 3 4 1  5 6 1  NB. a table of 2 lists
3 4 1
5 6 1
   $r
2 3
   p. r
+-+-----+
|1|_3 _1|
+-+-----+
|1|_5 _1|
+-+-----+
   $ p. r
2 2

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a list of y. If you get surprising results, see here.

Applies to p. p..


Rank 1 -- operates on lists of y, producing a list of variable length for each one

This verb operates on the lists of y (i. e. subarrays of rank 1, also called 1-cells). If y has rank greater than one, it is construed as an array of lists. If y is an atom, it is converted to a list of length 1 before being processed.

Applying the verb to a list produces a list whose length depends on y. ;: is an example of this type of verb:

   ;: 'Eschew obfuscation'
+------+-----------+
|Eschew|obfuscation|
+------+-----------+
   ;: 'Pick smaller words'
+----+-------+-----+
|Pick|smaller|words|
+----+-------+-----+

If y is an array of lists, the results of processing the individual lists are collected into the final result, adding framing fill if necessary. The overall result will have the same shape as y except that the last axis will have the length of the longest individual result:

   ]r =. 'Eschew obfuscation',:'Pick smaller words'
Eschew obfuscation
Pick smaller words
   ;: r
+------+-----------+-----+
|Eschew|obfuscation|     |
+------+-----------+-----+
|Pick  |smaller    |words|
+------+-----------+-----+

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a list of y, before fill is added. If you get surprising results, see here.

Applies to ;: C. I.


Rank 1 -- operates on lists of y, producing a result of variable shape for each one

This verb operates on the lists of y (i. e. subarrays of rank 1, also called 1-cells). If y has rank greater than one, it is construed as an array of lists. If y is an atom, it is converted to a list of length 1 before being processed.

Applying the verb to a list produces a result whose shape depends on y. ". is an example of this type of verb:

   ". '10 + 4'   NB. Result is an atom
14
   $". '10 + 4'

   ". 'i. 2 3'   NB. Result has shape 2 3
0 1 2
3 4 5
   $". 'i. 2 3'
2 3

If y is an array of lists, the results of processing the individual lists are collected into the final result, adding framing fill if necessary. The overall result will have the same shape as y except that the last axis will be replaced by the shape of the individual results after fill:

   ]r =. '10 + 4',:'i. 2 3'
10 + 4
i. 2 3
   $r   NB. r has 2 lists
2 6
   ". r
14 0 0
 0 0 0

 0 1 2
 3 4 5
   $". r  NB. ".r has 2 arrays of shape 2 3
2 2 3

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a list of y, before fill is added. If you get surprising results, see here.

Applies to { ". i.


Rank 2 -- operates on tables of y

This verb operates on the tables of y (i. e. subarrays of rank 2, also called 2-cells). If y has rank greater than 2, it is construed as an array of tables. If y has rank less than 2, it is processed as is; consult the verb to see what it produces for ranks less then 2.

Applying the verb to a table produces a result of fixed shape; the results from applying the verb on each table of y are collected into the final result, which will have the same shape as y except that the last 2 axes will be replaced by the shape of each individual result. %. is an example of this type of verb:

   ]r =. 2 2 $ 2 4 3 1
2 4
3 1
   %. r
_0.1  0.4
 0.3 _0.2
   ]r =. 3 2 $ 2 4 6 3 1 5
2 4
6 3
1 5
_0.0220386   0.190083 _0.0964187
 0.0936639 _0.0578512    0.15978

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a table of y. If you get surprising results, see here.

Applies to %. .


Rank Infinity -- operates on y as a whole

This verb operates on y in its entirety, producing a single result which may have any rank or shape, depending on the individual verb.

Applies to = < _: ^: $ $. $: ~ |. |: .. .: : :: , ,: ; ;. # #: [ ] } {:: ": `: @: m&v u&n &: &.: ?. b. L. L: s: S: u: x: 0:


Rank Infinity -- operates on y as a whole, by items

This verb operates on y in its entirety, but it acts on items of y independently. The items of an array y are the cells of y of rank one less than the rank of y. For example, the items of a list are atoms and the items of a table are lists. An atom has one item, itself.

Applies to ~. ~: ,. / /. /: \ \. \: {. {: }. }: e.


Rank 0 0 -- operates on individual atoms of x and y, producing a result of the same shape

This verb operates on atoms of x and y, producing a result with the shape of the larger operand. + is an example of this type of verb:

   1 2 3 + 100 200 300
101 202 303

If one of the operands is an atom, that atom is applied to each atom of the other operand:

   i. 2 3
0 1 2
3 4 5
   100 + i. 2 3
100 101 102
103 104 105

More generally, shorter operands are replicated to match the shape of larger ones, provided they agree.

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each atom of x v y . If you get surprising results, see here.

Applies to = < <. <: > >. >: + +. +: * *. *: - % %: ^ ^. ~: | ! b. H. j. o. r. t. t:


Rank 0 0 0 -- operates on individual atoms of [x and] y, producing a result of the same shape

This verb operates on atoms of [x and] y, producing a result with the shape of the larger operand. If x is omitted, a default is used for it. m b. is an example of this type of verb:

   0 1 0 (3 b.) 1 1 0
0 1 0

If one of the operands is an atom, that atom is applied to each atom of the other operand:

   0 1 0 (3 b.) 1
0 1 0

More generally, shorter operands are replicated to match the shape of larger ones, provided they agree.

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each atom of x v y . If you get surprising results, see here.

Applies to (m b.)


Rank 0 0 -- operates on individual atoms of x and y, producing a result that may require fill

This verb operates on corresponding atoms of x and y. If x or y is an array, the results from the atoms may have varying shapes, and are collected into the final result, adding framing fill if necessary. q: is an example of this type of verb:

   _ q: 700
2 0 2 1
   _ q: 702
1 3 0 0 0 1

If one of the operands is an atom, that atom is applied to each atom of the other operand:

   _ q: 700 702  NB. Fill required
2 0 2 1 0 0
1 3 0 0 0 1

More generally, shorter operands are replicated to match the shape of larger ones, provided they agree.

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to an atom of x and y. If you get surprising results, see here.

Applies to ? ?. q:


Rank 0 1 -- operates on individual atoms of x, and lists of y

This verb applies each atom of x to the corresponding list (i. e. subarray of rank 1, or 1-cell) of y. If y is an atom, it is treated as a list of length 1. p.. is an example of this type of verb:

   0 p.. 2 6 3
0 2 3 1

If x is a single atom, or y is a single list, that operand is applied to each cell of the other operand:

   0 2 p.. 2 6 3
0 2 3 1
2 2 3 1

More generally, shorter operands are replicated to match the shape of larger ones, provided they agree.

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to an atom of x and a list of y. If you get surprising results, see here.

Applies to p..


Rank 0 _ -- operates on atoms of x, and the entirety of y

This verb applies each individual atom of x to the entirety of y. x is considered as an array of atoms, and the verb is applied once between each atom of x and the entirety of y.

The results from the atoms of x may have varying shapes, and are collected into the final result, adding framing fill if necessary. { is an example of this type of verb:

   2 { 3 1 4 1 5 9   NB. select one item
4
   3 2 { 3 1 4 1 5 9  NB. each atom of x selects one item
1 4

If x is an array of atoms, the results of processing the individual atoms are collected into the final result, adding framing fill if necessary. The shape of the overall result will be the shape of x, extended by the shape of the individual results after fill:

   ]r =. i. 2 3
0 1 2
3 4 5
   (<1 1) { r   NB. select the atom in row 1 column 1
4
   1 { r     NB. select item 1
3 4 5
   1 1 ; 1   NB. A selector with two atoms (each box is an atom)
+---+-+
|1 1|1|
+---+-+
   (1 1 ; 1) { r   NB. Two selections; framing fill added
4 0 0
3 4 5

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to an atom of x and all of y, before fill is added. If you get surprising results, see here.

Applies to \ \. { m&v u&n A.


Rank 1 0 -- operates on lists of x, and individual atoms of y

This verb applies each list (i. e. subarray of rank 1, or 1-cell) of x to the corresponding atom of y. #: is an example of this type of verb:

   24 60 60 #: 1830
0 30 30

If x is a single list, or y is a single atom, that operand is applied to each cell of the other operand:

   24 60 60 #: 1830 3600
0 30 30
1  0  0

More generally, shorter operands are replicated to match the shape of larger ones, provided they agree.

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a list of x and an atom of y, before fill is added. If you get surprising results, see here.

Applies to #: p.


Rank 1 1 -- operates on lists of x and y

This verb applies each list (i. e. subarray of rank 1, or 1-cell) of x to the corresponding list of y. If x or y is an atom, it is treated as a list of length 1. #. is an example of this type of verb:

   24 60 60 #. 0 30 30
1830

If x or y is a single list, that operand is applied to each list of the other operand:

   ]r =. 0 30 30 ,: 1 0 2
0 30 30
1  0  2
   24 60 60 #. r
1830 3602

More generally, shorter operands are replicated to match the shape of larger ones, provided they agree.

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a list of x and a list of y, before fill is added. If you get surprising results, see here.

Applies to #.


Rank 1 _ -- operates on lists of x and the entirety of y

This verb applies each list (i. e. subarray of rank 1, or 1-cell) of x to the entirety of y. If x is an atom, it is treated as a list of length 1. The shape of the result of applying one cell of x to y depends on the values of x and y.

{. is an example of this type of verb:

   2 {. 5 6 7   NB. Take first 2 items of list
5 6
   ]r =. i. 3 4
0 1  2  3
4 5  6  7
8 9 10 11
   2 {. r    NB. Take first 2 items of table
0 1 2 3
4 5 6 7
   2 3 {. r  NB. Take first 2 rows, first 3 columns
0 1 2
4 5 6

If x is an array of lists, the results of processing the individual lists are collected into the final result, adding framing fill if necessary. The overall result will have the same shape as x except that the last axis will be replaced by the shape of the individual results after fill:

   ]l =. 2,:3  NB. l is 2 lists
2
3
   l {. r     NB. The results from each list collected with fill
0 1  2  3
4 5  6  7
0 0  0  0

0 1  2  3
4 5  6  7
8 9 10 11
   $l {. r
2 3 4

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a list of x and all of y, before fill is added. If you get surprising results, see here.

Applies to $ |. |: {. {:: }. C.


Rank 1 _ -- operates on lists of x and the entirety of y, with replication of atomic x

This verb applies each list (i. e. subarray of rank 1, or 1-cell) of x to the entirety of y. If x is an atom, it is replicated so as to apply uniformly across y. The shape of the result of applying one cell of x to y depends on the values of x and y.

# is an example of this type of verb:

   1 0 1 # 3 1 4   NB. Items of x and y match
3 4
   2 # 3 1 4     NB. Atom of x replicated to match y
3 3 1 1 4 4

If x is an array of lists, the results of processing the individual lists are collected into the final result, adding framing fill if necessary. The overall result will have the same shape as x except that the last axis will be replaced by the shape of the individual results after fill:

   ]l =. 1 1 0,:0 0 1   NB. Two selectors
1 1 0
0 0 1
   l # 3 1 4    NB. Results collected with fill
3 1
4 0

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a list of x and all of y, before fill is added. If you get surprising results, see here.

Applies to # ": ;.1 ;.2


Rank 2 _ -- operates on tables of x and the entirety of y

This verb applies each table (i. e. subarray of rank 2, or 2-cell) of x to the entirety of y. If x has rank less than 2, it is extended to a single table. The shape of the result of applying one table of x to y depends on the values of x and y.

u;.0 is an example of this type of verb:

   ]r =. i. 4 5
 0  1  2  3  4
 5  6  7  8  9
10 11 12 13 14
15 16 17 18 19
   ]l =. 1 1,:2 3  NB. a 2x2 selector, to take a 2x3 block starting at (1,1)
1 1
2 3
   l ];.0 r
 6  7  8
11 12 13

If x is an array of tables, the results of processing the individual tables are collected into the final result, adding framing fill if necessary. The overall result will have the same shape as x except that the last two axes will be replaced by the shape of the individual results after fill:

   ]ll =. l ,: 0 0,:2 3  NB. 2 selectors
1 1
2 3

0 0
2 3
   ll ];.0 r   NB. The 2 selections
 6  7  8
11 12 13

 0  1  2
 5  6  7

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to a table of x and all of y, before fill is added. If you get surprising results, see here.

Applies to ;.0 ;.3


Rank _ 2 -- operates on the entirety of x and tables of y

This verb applies the entirety of x to each table (i. e. subarray of rank 2, or 2-cell) of y. If x or y has rank less than 2, it is extended to a single table. The shape of the result of applying one table of x to y depends on the values of x and y.

%. is an example of this type of verb:

   ]r =.1 2,:2 1   NB. A 2x2 matrix
1 2
2 1
   9 12 %. r
5 2

If y is an array of tables, the results of processing the individual tables are collected into the final result. The overall result will have the same shape as y except that the last two axes will be replaced by the shape of the individual results:

   ]rr =. r ,: 2 3,:3 2  NB. Two 2x2 matrices
1 2
2 1

2 3
3 2
   9 12 %. rr   NB. One result from each
  5   2
3.6 0.6

If you use this verb as the v in u@v, u&v, or u&.v, u will be applied individually to each result of applying v to all of x and a table of y, before fill is added. If you get surprising results, see here.

Applies to %.


Rank Infinity -- operates on x and y as a whole

This verb operates on x and y in their entirety, producing a single result which may have any rank or shape, depending on the individual verb.

Applies to _: -: $. $: . ; ;: / (m :n) [ ] } ". `: @: &: &.: E. L: p: s: S: u: x: 0:


Rank Infinity -- operates on [x and] y as a whole

This verb operates on x and y in their entirety, producing a single result which may have any rank or shape, depending on the individual verb.

Argument x may or may not be present.

Applies to ^: :: [: 0: to 9: _1: to _9: _: hook fork


Rank Infinity -- operates on x and y as a whole, after adjusting the smaller operand

This verb operates on x and y in their entirety. Depending on the verb, either items of x and y, or the entirety of x and y, are matched together.

If the matched parts of x or y is an atom, it is replicated to the size of the corresponding matched part. If the matched parts of x and y differ in rank, the operand of smaller rank is brought up to the rank of the larger by adding leading axes of length 1.

The items of an array are the cells whose rank is one less than the rank of the array. For example, the items of a list are atoms and the items of a table are lists. An atom has one item, itself.

Applies to , ,. ,:


Rank Infinity -- operates on x and y as a whole, by items of y

This verb operates on x and y in their entirety, but it acts on cells that have the rank of items of y. The items of an array y are the cells of y whose rank is one less than the rank of y. For example, the items of a list are atoms and the items of a table are lists. An atom has one item, itself.

Applies to e.


Rank Infinity -- operates on x and y as a whole, by items of x

This verb operates on x and y in their entirety, but it acts on cells that have the rank of items of x. The items of an array x are the cells of x whose rank is one less than the rank of x. For example, the items of a list are atoms and the items of a table are lists. An atom has one item, itself.

Applies to -. i. i: I.


Rank Infinity -- operates on x and y as a whole, by items

This verb operates on x and y in their entirety, but it acts on the items of each. The items of an array are the cells whose rank is one less than the rank of the array. For example, the items of a list are atoms and the items of a table are lists. An atom has one item, itself.

Applies to /. /: \:


Rank depends on the rank of u

The primitive you are examining is a modifier, either an adverb that takes an operand to its left, as in verbname f. or a conjunction that takes an operand to its left and right, as in #. :. #:. The modifier executes to produce a derived verb. The rank of this verb depends on the ranks of the u operand.

Applies to ~ :. D. D: f. M.


Rank depends on the rank of v

The primitive you are examining is a conjunction that takes an operand to its left and right, as in #@>. The modifier executes to produce a derived verb. The rank of this verb depends on the ranks of the v operand.

Applies to @ @. u&v &.


Rank depends on the rank of u and v

The primitive you are examining is a conjunction that takes an operand to its left and right, as in > : *. The modifier executes to produce a derived verb. The rank of this verb depends on the ranks of the two operands.

Applies to u : v