Created
February 27, 2011 12:42
-
-
Save jsoffer/846151 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
porTresMasUno :: [Bool] -> [Bool] | |
porTresMasUno xs = False : ys ++ residuo where | |
cs = True : zipWith3 gc cs (tail xs) xs | |
gc b = if b then (||) else (&&) | |
ys = zipWith3 gy cs (tail xs ++ [False]) xs | |
gy p q r = (p /= q) /= r | |
residuo = if last cs then [True] else [] | |
serie :: String -> [[Bool]] | |
serie s = takeWhile (not.alto) $ iterate paso $ leer s where | |
leer = map (\k -> if k == '0' then False else True) | |
paso xs = ceros ++ siguiente where | |
(ceros,actual) = break id xs | |
siguiente = porTresMasUno actual | |
alto xs = (length $ filter id xs) == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment