[Haskell-beginners] Auto-increment String
John M. Dlugosz
ngnr63q02 at sneakemail.com
Fri Apr 18 22:51:19 UTC 2014
On 4/18/2014 2:38 PM, Norbert Melzer wrote:
> > "a" to "z" then "aa" to "zz" then "aaa" to "zzz" and so on! Is it to difficult or
> impossible to create a function that enumerates all possible strings?
> Following your theory the next "name" would be "Joho", is that a name or just random
> letters? That's why you don't have predecessor or successor functions on String.
That's how it works in Perl.
perl -e "$x='John'; ++$x; print $x; "
It would be an interesting beginner's exercise to implement that in Haskell (re:
A foldr would be good, I suppose, but complicated by the need to return the carry state as
well as the accumulated tail to the next iteration.
More information about the Beginners