Thomas Davie wrote: > letterCombos = map (:[]) ['a'..'z'] ++ concatMap (\c -> map ((c++) . (: > [])) ['a'..'z']) letterCombos > > Not hugely efficient, if you generate the strings in reverse then you > can use (c:) rather than ((c++) . (:[])), but that may not be useful > to you. > > Bob
I think the following version increases the sharing between the generated strings, and so might be more space-efficient for consumers which hold on to a significant number of them: number :: [a] -> [[a]] number digits = expand [[]] where expand xss = expanded ++ expand expanded where expanded = concatMap (\d -> map (d:) xss) digits binary = number ['0'..'1'] decimal = number ['0'..'9'] alpha = number ['a'..'z'] Regards, Matthew _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe