Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!utcsri!geac!jtsv16!itcyyz!yrloc!hui
From: hui@yrloc.ipsa.reuter.COM (Roger Hui)
Subject: Re: Reflected Gray Codes
Message-ID: <1993Mar1.040824.8429@yrloc.ipsa.reuter.COM>
Organization: None
Date: Mon, 1 Mar 93 04:08:24 GMT

Ken Iverson points out that since the binary numbers and the reflected
gray codes are related b=~:/\"1 g, it follows g=~:/\^:_1"1 b.  Thus:
 
   bin  =. #: @ i. @ (2&^)
   gray =. ~:/\^:_1"1 @ bin
 
   bin 3         gray 3
0 0 0         0 0 0
0 0 1         0 0 1
0 1 0         0 1 1
0 1 1         0 1 0
1 0 0         1 1 0
1 0 1         1 1 1
1 1 0         1 0 1
1 1 1         1 0 0
 
Several other methods of generating the binary numbers and the
reflected gray codes are described in the Vector article
"Three Combinatoric Puzzles", Volume 9, Number 2, 1992 10.
