# Vocabulary/slashdot

Rank Infinity -- operates on x and y as a whole, by items of y -- WHY IS THIS IMPORTANT?

(u/.y) applies verb u to the oblique diagonals of table y

] y=: 4 4 \$ i.3
0 1 2 0
1 2 0 1
2 0 1 2
0 1 2 0
</. y
+-+---+-----+-------+-----+---+-+
|0|1 1|2 2 2|0 0 0 0|1 1 1|2 2|0|
+-+---+-----+-------+-----+---+-+

### Common Uses

1. As part of the idiom for polynomial multiplication

(1 2) */ (3 4 2)         NB. consider this product
3 4 2
6 8 4
+/ /. (1 2) */ (3 4 2)    NB. sum up the oblique diagonals
3 10 10 4
pmul =: +//.@(*/)         NB. define a dyadic verb to calculate the coefficients
1 2 pmul 3 4 2            NB. of e.g. (2x+1)(2x^2+4x+3)=4x^3+10x^2+10x+3
3 10 10 4

1. u can be a cyclic gerund.

### Details

1. The arguments to the invocations of u are lists of (_2)-cells of y

2. If y has no items, the result of u/. y will also have no items.

However, u will be executed once on a cell of 0 _2-cells to establish the shape of a result of u, and then the result of  u/. y will be a list of 0 of that shape

\$ ]/. i. 0 3    NB. u is executed on a cell of shape 0
0 0
\$ ]/. i. 0 3 4  NB. u is executed on a cell of shape 0 4
0 0 4

### Use These Combinations

Combinations using u/. y that have exceptionally good performance are shown in Diagonals and Polynomials.

Rank Infinity -- operates on x and y as a whole, by items -- WHY IS THIS IMPORTANT?

Classifies items of x into partitions of identical items. Then y is partitioned using the partitioning that was calculated for x, and u is applied on each partition of y.

Note: x and y must have the same number of items.

Noun x is used only for the partitioning and is not an argument to operand u. In other words, each item of x is the key of the corresponding item of y, and u is applied to each set of items of y with equal keys

y=: 'AbcDeFGhijk'
] x=: y e. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'   NB. 1=uppercase, 0=lowercase
1 0 0 1 0 1 1 0 0 0 0

x ]/. y
bcehijk
x </. y
+----+-------+
+----+-------+

### Common Uses

1. Count the number of different items using  #/.

a =: 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
(~.a) ,: (a #/. a)                    NB. digits, then frequency of each
3 1 4 5 9 2 6 8 7
2 2 1 3 3 1 1 1 1

2. Collect information from records with identical keys

]data =: _2 ]\ 'Fred';90;'John';75;'Fred';95;'John';85;'Susan';100;'John';86   NB. A table
+-----+---+
|Fred |90 |
+-----+---+
|John |75 |
+-----+---+
|Fred |95 |
+-----+---+
|John |85 |
+-----+---+
|Susan|100|
+-----+---+
|John |86 |
+-----+---+
]s =: ({."1 data) <@;/. ({:"1 data)   NB. Use first column as keys; collect second-column values
+-----+--------+---+
|90 95|75 85 86|100|
+-----+--------+---+
(~. {."1 data) ,. s                   NB. Reinstall the name
+-----+--------+
|Fred |90 95   |
+-----+--------+
|John |75 85 86|
+-----+--------+
|Susan|100     |
+-----+--------+

1. u can be a cyclic gerund

x tolower`toupper/. y
BCEHIJK

### Details

1.  x u/. y is a member of the i.-family.

2. The argument to each invocation of u is a list of items of y (this has the same rank as y unless y is an atom).

3. The partitions are processed in the same order as the items in  ~. x .

4. The partitioning uses tolerant comparison. Use u/.!.0 for intolerant comparison.

5. If y has no items, the result of  x u/. y will also have no items.

However, u will be executed once on a cell of 0 items to establish the shape of a result of u, and then the result of  x u/. y will be a list of 0 of that shape

\$ '' ]/. ''        NB. u is executed on cell of shape 0
0 0
\$ '' {./. ''       NB. u produces an atomic result
0
\$ '' {./. i. 0 3   NB. u is executed on cell of shape 0 3
0 3

---

### Oddities

If a tolerance is specified using u/.!.f, that tolerance is used as the default tolerance during the execution of u. ---

### Use These Combinations

Combinations using x u/. y that have exceptionally good performance are shown in Partitions and Diagonals and Polynomials.