Skip to content

Instantly share code, notes, and snippets.

@mstahl
Created January 17, 2009 01:16
Show Gist options
  • Save mstahl/48230 to your computer and use it in GitHub Desktop.
Save mstahl/48230 to your computer and use it in GitHub Desktop.
{-
sequence.hs
Generates the funky 1, 11, 21, 1211, ... sequence.
-}
import Data.List
next_in_sequence s = foldl1 (++) $ map (\x -> [length x, head x]) $ group s
funky_sequence = iterate next_in_sequence [1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment