# Vocabulary/ampdot

 [x] u&.v y Under (Dual) Conjunction

Rank -- depends on the rank of v -- WHY IS THIS IMPORTANT?

Executes v on the argument(s) cell-by-cell.

• For each cell, u is applied to the result(s) of v
• Then v^:_1 (i.e. the obverse of v) is applied to the result of u — giving the result for that cell.

Finally the results for all cells are collected into the end result.

In mathematical terms:

• Verb v defines a transformation of the argument(s) (x and) y into the v-domain
• Next, verb u operates on the transformed argument(s)
• Lastly the result is transformed back from the v-domain to the original domain.

We say that u is applied under v .

Example: Apply (i.) to the contents of each box separately, and re-box each result separately

```   ] y =: 1;2;2 3
+-+-+---+
|1|2|2 3|
+-+-+---+

u =: i.
v =: >
u&.v y
+-+---+-----+
|0|0 1|0 1 2|
| |   |3 4 5|
+-+---+-----+
```

### Common uses

1. The most common use of &. is [x] u&.> y which applies the verb u inside each box of the arguments. This follows the rules above: u&.> has rank 0 regardless of u, so each box is opened separately, operated on, and then reboxed.

Examples:

Convert a list of boxed strings to uppercase

```   ] z =: ;:'alpha bravo charlie'
+-----+-----+-------+
|alpha|bravo|charlie|
+-----+-----+-------+
toupper&.> z
+-----+-----+-------+
|ALPHA|BRAVO|CHARLIE|
+-----+-----+-------+
```

Add the contents of corresponding boxes

```   ]l =. 1;2 3;4 5 6
+-+---+-----+
|1|2 3|4 5 6|
+-+---+-----+
]r =. 3 1 4;1 5;9
+-----+---+-+
|3 1 4|1 5|9|
+-----+---+-+
l +&.> r
+-----+---+--------+
|4 2 5|3 8|13 14 15|
+-----+---+--------+
```

The standard library defines the name each as &.>

```   (<'Mr. ') , each 'Smith';'Jones'
+---------+---------+
|Mr. Smith|Mr. Jones|
+---------+---------+
```

each is a

• Standard Library word(s) residing in the 'z'-locale
• Defined in the factory script stdlib.ijs which is located in  ~system/main/stdlib.ijs
• View the definition(s) in a JQt session by entering:  open '~system/main/stdlib.ijs'

2. A useful trick is to use each when one or more arguments are not boxed. Since > y leaves y unchanged if it is not boxed, an unboxed argument will be processed as individual unboxed atoms:

```   i.&.> 3 4  NB. i. on each atom, boxing results separately
+-----+-------+
|0 1 2|0 1 2 3|
+-----+-------+
3 3 4 {. each 'Washington';'Sheffield';'Hereford'
+---+---+----+
|Was|She|Here|
+---+---+----+
100 + each 3;1 4;1 5 9   NB. Add 100 inside each box
+---+-------+-----------+
|103|101 104|101 105 109|
+---+-------+-----------+
```

### Semiduals x u&.(a:`v) y and x u&.(v`a:) y

The operation encapsulated by u&.v is used often and is important as a notation to aid thought. When the operation is dyadic, sometimes the sequence of transforming/operating/transforming back should be applied to just one argument, with the other argument being passed unchanged into u. This can be represented by a gerund form where a: indicates which argument is to be used unmodified. The form using &. is defined in terms of the infinite-rank version &.::

• x u&.(a:`v) y is x u&.:(a:`v)"(lu,mv) where lu is the left rank of u and mv is the monadic rank of v
• x u&.(v`a:) y is x u&.:(v`a:)"(mv,ru) where ru is the right rank of u and mv is the monadic rank of v
```   <"2 i. 3 2 4   NB. y is 3 boxes
+-------+-----------+-----------+
|0 1 2 3| 8  9 10 11|16 17 18 19|
|4 5 6 7|12 13 14 15|20 21 22 23|
+-------+-----------+-----------+
100 200 +"_&.(a:`>) <"2 i. 3 2 4  NB. open y (but not x), add x to each contents, rebox
+---------------+---------------+---------------+
|100 101 102 103|108 109 110 111|116 117 118 119|
|204 205 206 207|212 213 214 215|220 221 222 223|
+---------------+---------------+---------------+
+"_&.(a:`>) b. 0  NB. This works because the left rank of u&.(a:`v) comes from u
0 _ 0
```

Under (&.:)