# $ Enumerate¶ x$y    $[x;y] Where • x and y are lists • x~distinct x • items of y are all items of x returns y as an enumeration of x. Using built-in Enumerate: q)show e:x$y;
x$abcbabccccccc Values are stored as indexes and so need less space. q)"i"$e
0 1 2 1 0 1 2 2 2 2 2 2 2i

Changing one lookup value (in x) has the same effect as changing those values in the enumeration, while the indexes backing e are unchanged.

q)x[0]:o
q)e
x$obcbobccccccc q)"i"$e
0 1 2 1 0 1 2 2 2 2 2 2 2i

To get x and y from e:

q)(key;value)@\:e
x
obcbobccccccc

Ensure all items of y are in x

When creating an enumeration using $, the domain of the enumeration must be in x, otherwise a cast error will be signalled. q)y:abcbabccccccc q)x:ab q)x$y
'cast

To expand the domain, use ? (Enum Extend) instead of \$.

## Errors¶

error cause
cast item/s of y not in x`