Skip to content

Instantly share code, notes, and snippets.

@Tener
Created September 17, 2011 20:19
Show Gist options
  • Save Tener/1224321 to your computer and use it in GitHub Desktop.
Save Tener/1224321 to your computer and use it in GitHub Desktop.
Slow generation of "look and say" sequence
import Data.List
import System.IO
say :: Integer -> Integer
say = read . concatMap saygroup . group . show
where saygroup s = (show $ length s) ++ [head s]
look_and_say :: [Integer]
look_and_say = 1 : map say look_and_say
pr (x,y) = do
hPrint stderr x
print x
print (x,y)
main :: IO ()
main = mapM_ pr (zip [0..] look_and_say)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment