How to generate a list of all possible strings from shortest to longest

前端 未结 4 1134
滥情空心
滥情空心 2021-02-09 05:03

I need to generate an infinite list of strings using numbers and letters. The first string should simply be \"a\", then \"b\" through to \"z\", then \"0\" through to \"9\", the

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-09 05:36

    This can be done simply by a predefined function replicateM from (Control.Monad).

    string = concatMap (\n -> replicateM n (['a'..'z']++['0'..'9'])) [1..]
    

提交回复
热议问题