diff options
Diffstat (limited to 'H49.hs')
-rw-r--r-- | H49.hs | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -0,0 +1,8 @@ +import Control.Monad (replicateM) + +gray = map construct . (flip replicateM) ['0','1'] + where construct x = zipWith (\a b -> if a == b then '0' else '1') ('0':x) x + +gray' :: Integral a => a -> [String] +gray' 0 = [""] +gray' n = foldr (\s acc -> ("0" ++ s):("1" ++ s):acc) [] $ gray (n-1) |