[Haskell-beginners] comma delimited string

Daniel Fischer daniel.is.fischer at web.de
Thu Oct 14 14:32:09 EDT 2010


On Thursday 14 October 2010 20:17:25, Bryce Verdier wrote:
> Hi All,
>
> I have a file with a bunch of lines like such.
> number,number,string,string,string,string
>
> How can I split up the lines in Haskell so that each item in the line
> becomes an element in a list? Or to put it differently, how do I split
> up a comma delimited string?

For example

http://hackage.haskell.org/packages/archive/split/0.1.2.1/doc/html/Data-
List-Split.html#v:splitWhen

http://hackage.haskell.org/packages/archive/split/0.1.2.1/doc/html/Data-
List-Split.html#v:splitOn

http://hackage.haskell.org/packages/archive/split/0.1.2.1/doc/html/Data-
List-Split.html#v:splitOneOf

do that for lists.

There's similar functionality for ByteStrings (bytestring, stringsearch) 
and for Text (text).

>
> Thanks in advance,
>
> Bryce



More information about the Beginners mailing list