## # y (Tally)

Counts the items in a list

```   # 'abc'
3
# 'a'
1```

Note that the result of # is an atom (a scalar value), whereas the result of using \$ in place of # is a list of 0 or more items

```   \$ (# 'abc')

\$ (# 'a')

\$ (\$ 'abc')
1
\$ (\$ 'a')
0```

### Common uses

1. Count the rows of a 2-matrix

```   i.3 4
0 1  2  3
4 5  6  7
8 9 10 11
# i.3 4
3```
• Relies on the fact that a 2-matrix in J is a list of lists

2. Count the (hyper)planes of a 3-matrix, or higher rank

```   # i.3 4 5
3
# i.3 4 5 6
3```

Neater than extracting the Head ({.) of the Shape Of (\$) the given matrix

```   mx=: i.3 4 5 6
\$mx
3 4 5 6
{.\$mx
3```

## x # y (Copy)

Copies each item of a list y according to the corresponding integer value in list x.

```   1 2 3 # 'abc'
abbccc```

If x is an atom (a scalar value) then it is effectively reshaped to the shape of y

```   3 # 'abc'
aaabbbccc```

### Common uses

1. Delete selected item(s) of list y

• Mask x has 1 for each item to be kept, and 0 for each item to be deleted.

```   1 0 1 # 'abc'
ac```

2. Duplicate a given letter in a string, e.g. Quote (')

```   ]z=: 'it''s'
it's
z=''''
0 0 1 0
1+z=''''
1 1 2 1
(1+z='''') # z
it''s```

Note: the library verb quote_z_ uses (#) to duplicate all Quotes inside the given string

```   ]z=: 'it''s'
it's
quote z
'it''s'```