## \$ y (Shape Of)

Returns the shape of the noun y .

The shape of a given noun is...

• empty (i.0) for an atom (eg the single letter 'a')

• the number of atoms for a vector (eg a list of numbers)
• 0 for the empty vector

• (3 2) for a 3-by-2 matrix

```   \$ y=: 'a'

\$ \$ y
0
(i.0) -:  \$ y=: 'a'
1

\$ y=: 'abcdefghijkl'
12

] y=: 'abc' ,: 'def'
abc
def
\$ y
2 3```

Warning Shape Of (\$) behaves differently to Tally (#) (which counts the items in a list).

```   (\$ ; #) y=: ''
+-+-+
|0|0|
+-+-+
(\$ ; #) y=: 'a'
++-+
||1|
++-+
(\$ ; #) y=: ,'a'
+-+-+
|1|1|
+-+-+
(\$ ; #) y=: 'abc'
+-+-+
|3|3|
+-+-+```

### Common uses

1. To verify if a noun is empty, an atom, or a list.

```   \$ y=: ''
0
\$ y=: 'a'

\$ y=: ,'a'
1
\$ y=: ,'abc'
3```

2. To check that two matrices have the same number of entries in the same arrangement.

• Several primitive dyadic verbs are shape-dependent and give an error if x and y are incompatible.

```   ] y=: 2 3 \$ 'abcdef'
abc
def
] x=: 4 5 \$ 'ABCDEF'
ABCDE
FABCD
EFABC
DEFAB

\$ x,y
6 5
\$ x,:y
2 4 5
\$ x,.y
|length error
|   \$x    ,.y
\$ x,.x
4 10```

## x \$ y (Shape)

Changes the Shape Of (\$) (or re-shapes) the array y to (a vector derived from) x.

```   \$ y=: 'abcdefghijkl'
12
] z=: 2 2 \$ y
ab
cd
\$ z
2 2```

Warning the resulting Shape Of z (\$z -- where z=:x\$y)) is not necessarily x unless the items of y are atoms!

```   y=: 'abcdefghijkl'
\$ z=: 2 2 \$ y
2 2
y=: 3 4\$'abcdefghijkl'
\$ z=: 2 2 \$ y
2 2 4```

### Common uses

1. To create a matrix from a unidimensional list.

2. To change the arrangement of entries in a matrix.