The general solution for generating a Gray code sequence, by definition of “reflected binary”, is to recursively reverse and concatenate. Here’s how that might go:

[""], { |.map(0 ~ *), |.reverse.map(1 ~ *) } … ∞

Subscripting the above with .[$N] would give a sequence of $N-bit binary numbers, so to see the sequence in decimal form you’d have to call .map: *.parse-base: 2 on it.

We can do this a lot shorter, however, if we cheat. Instead of generating a sequence, we can convert from every number (or index, rather) to its corresponding Gray code:

^∞ Z+^ (^∞ X+> 1)

This is basically the old “Kth Gray code is K^(K>>1)” algorithm on a diet. To get the $N-bit sequence, subscript it with .[^2**$N].