In Haskell I can generate the alphabet as follows:
alfabeto = ['a'..'z']
To display it simply:
alfabeto
"abcdefghijklmnopqrstuvwxyz"
However, I'd like to know how I can put a space between the letters, like this:
"a b c d e f g h ..."
In Haskell I can generate the alphabet as follows:
alfabeto = ['a'..'z']
To display it simply:
alfabeto
"abcdefghijklmnopqrstuvwxyz"
However, I'd like to know how I can put a space between the letters, like this:
"a b c d e f g h ..."
The module Data.List
has the function intersperse
that does just that. See it at GHCi:
Prelude> :m + Data.List
Prelude Data.List> intersperse ' ' ['a'..'z']
"a b c d e f g h i j k l m n o p q r s t u v w x y z"