[Haskell-cafe] Need some help with an infinite list

Dean Herington heringtonlacey at mindspring.com
Wed Jun 17 00:45:56 EDT 2009


At 4:25 PM +1200 6/17/09, Richard O'Keefe wrote:
>On 17 Jun 2009, at 2:01 pm, Richard O'Keefe wrote:
>On second thoughts,
>
>   let strings = "" : [pref++[last] | pref <- strings, last <- ['a'..'z']]
>   in tail strings
>
>seems more Haskellish than the stupidly clever counting-based
>code I had in mind.  With this it's much easier to see what it's up to.

And here's a version along similar lines that avoids (++) for greater 
sharing and efficiency:

   let sss = [""] : [ [ c:s | c <- ['a'..'z'], s <- ss ] | ss <- sss ] 
in concat (tail sss)


More information about the Haskell-Cafe mailing list