3

Is there an easy way to change [Int] -> String ? My output function returns a list of int but the format should be a string as in the example below

example: [1,2,3,4] -> 1 2 3 4

Marc Zaharescu
  • 629
  • 1
  • 13
  • 34

1 Answers1

7

To turn an integer into a string, use show.

To turn a list of integers into a list of strings, use map show.

To add " " between every string in a list of strings, use intersperse " ". (Requires import Data.List)

To concatenate a list of strings, use concat.

Alternative: try unwords ["a","b","c"] in GHCi.

chi
  • 111,837
  • 3
  • 133
  • 218