Created
May 19, 2016 05:16
-
-
Save recurse/fa5255558e5dcffd82525271538bd92c 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
next :: [Int] -> [Int] | |
next [] = [] | |
next (i1:is) = case is of | |
[] -> [0] | |
i2:_ -> i2:(next' i1 is) where | |
next' l [] = [l] | |
next' l (i:is) = case is of | |
[] -> [i] | |
r:_ -> (l `xor` r):(next' i is) where | |
xor 0 0 = 0 | |
xor 1 0 = 1 | |
xor 0 1 = 1 | |
xor 1 1 = 0 | |
doCA :: Int -> [Int] -> [[Int]] | |
doCA n s = take n $ scanl doNext s [0..] where | |
doNext l _ = next l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment