Sarah
Sarah

Reputation: 19

How can we split the list elements in new lines

I am still a beginer in Haskell and I want to know how can I split the numbers in a list in new lines so each line contains one element of the list.

Upvotes: 1

Views: 1376

Answers (1)

Lanbo
Lanbo

Reputation: 15692

If you have a [Char], a String, you may use the function lines that splits it... But I think what you're looking for is this:

as_lines l = unlines $ map show l

unlines :: [String] -> String concatenates the given Strings, using a newline as the connector. I hope this does what you want.

Upvotes: 5

Related Questions