Created
January 28, 2011 15:09
-
-
Save jsoffer/800359 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
zipWithN f = foldl1 (zipWith f) | |
generar :: String -> [Int] -> [Bool] | |
generar inicial indices = ts where | |
ts = xs ++ zipWithN (/=) (g indices) | |
xs = map (== '1') inicial | |
g = map ((flip drop) ts) | |
leer n xs = take n $ map (\k -> if k then '1' else '0') xs | |
-- let t1 = generar "1001" [1,3] | |
-- "1001" cadena inicial | |
-- [1,3] los índices del registro que se suman | |
-- leer 100 t1 -- produce 100 bits con esos parámetros | |
-- cadena inicial no muy validada, '1' es '1', cualquier otra letra es '0' | |
-- no verifica si los índices rebasan la cadena inicial; puede causar ciclos | |
-- infinitos o errores en ese caso |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment