Sunday, 5 June 2016

Haskell: lines: split text on line boundaries

Haskell provides a built-in library function; it takes a string as input and split the string on new line (\n) boundaries.

*Main> :t lines

lines :: String -> [String]
*Main> let text = "Hello, How are you PTR\nI am fine what about you\nYa I am superb"
*Main> text
"Hello, How are you PTR\nI am fine what about you\nYa I am superb"
*Main> 
*Main> lines text
["Hello, How are you PTR","I am fine what about you","Ya I am superb"]
*Main> 



Previous                                                 Next                                                 Home

No comments:

Post a Comment