Created
December 4, 2019 16:05
-
-
Save mizunashi-mana/34c6f7363fda7e9fe79688aee11dea4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BitSeq where | |
merge :: Int -> [a] -> [a] -> [a] | |
merge n xs ys = goXs n xs | |
where | |
goXs 0 zs = goYs n ys zs | |
goXs m (z:zs) = z:goXs (m - 1) zs | |
goXs _ [] = error "unreachable" | |
goYs 0 zs r = merge (n + 1) r zs | |
goYs m (z:zs) r = z:goYs (m - 1) zs r | |
goYs _ [] _ = error "unreachable" | |
-- | | |
-- | |
-- >>> take 10 ns | |
-- [[],[0],[1],[0,0],[0,1],[1,0],[1,1],[0,0,0],[0,0,1],[0,1,0]] | |
-- | |
ns :: [[Int]] | |
ns = let l = []:merge 1 [0:xs | xs <- l] [1:xs | xs <- l] in l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment