Look and say sequence (Haskell)

From LiteratePrograms

Jump to: navigation, search
Other implementations: C++ | dc | Eiffel | Haskell | J | Java | Lua | OCaml | Perl | PHP | Python | Ruby | Scala | sed | sh

This program is a code dump.
Code dumps are articles with little or no documentation or rearrangement of code. Please help to turn it into a literate program. Also make sure that the source of this code does consent to release it under the MIT or public domain license.

This is a simple Haskell program to generate look-and-say sequences such as the Conway sequence.

<<LookAndSaySequence.Haskell>>=
import Data.List (group)
sayit::[Int]->[Int]
sayit = concatMap (\g -> [length g, head g]) . group
sayitall::[Int]->Int->[[Int]]
sayitall s n = take n $ iterate sayit s
main = do print " The result is "
          print (sayitall [3] 10)
Download code
Views