Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert list of numbers to list of strings in Haskell

How to convert list of numbers to list of strings(one string = one number from list) in Haskell.

[Int] -> [String]

Examples: [1,2,3,4] -> ["1","2","3","4"]

like image 975
Philimon_kf Avatar asked Sep 20 '25 00:09

Philimon_kf


1 Answers

If you have a function f :: a -> b, then map f :: [a] -> [b] applies f on all the list elements.

The function show can convert "printable" types in their string representation. In particular, one of the possible types for show is Int -> String.

Use both tools.

like image 161
chi Avatar answered Sep 22 '25 16:09

chi