graycode - Maple Help

combinat

 graycode
 list of the n-bit numbers in graycode order

 Calling Sequence graycode(n)

Parameters

 n - non-negative integer

Description

 • The procedure graycode computes and returns a list containing all ${2}^{n}$ n-bit integers in a graycode order starting at zero.
 • A graycode order is such that each successive pair of integers differ in only one bit in their binary representations.
 • The command with(combinat,graycode) allows the use of the abbreviated form of this command.

Examples

 > $\mathrm{with}\left(\mathrm{combinat},\mathrm{graycode}\right)$
 $\left[{\mathrm{graycode}}\right]$ (1)
 > $\mathrm{graycode}\left(0\right)$
 $\left[{0}\right]$ (2)
 > $\mathrm{graycode}\left(1\right)$
 $\left[{0}{,}{1}\right]$ (3)
 > $g≔\mathrm{graycode}\left(3\right)$
 ${g}{≔}\left[{0}{,}{1}{,}{3}{,}{2}{,}{6}{,}{7}{,}{5}{,}{4}\right]$ (4)
 > $\mathrm{printf}\left(\mathrm{cat}\left(\mathrm{}\left(\mathrm{ %.3d},8\right)\right),\mathrm{op}\left(\mathrm{map}\left(\mathrm{convert},g,\mathrm{binary}\right)\right)\right)$
 000 001 011 010 110 111 101 100