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

Henning Thielemann lemming at henning-thielemann.de
Wed Jun 17 05:17:12 EDT 2009


On Wed, 17 Jun 2009, 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

last:pref instead of pref++[last] should do more sharing.

You can also write it this way:

   let strings = "" : Monad.liftM2 (flip (:)) strings ['a'..'z']
   in  tail strings


More information about the Haskell-Cafe mailing list