Gray code by ho

f 0=[""]
f n=map('0':)(f(n-1))++map('1':)(reverse$f(n-1))
main=interact$ \n->"Gray code  n="++n++unlines(f(read n))

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page