[Haskell-cafe] How to split this string.

Yves Parès limestrael at gmail.com
Mon Jan 2 12:07:07 CET 2012


Okay, so it doesn't handle different line-endings.

I have a more general solution (statefulSplit)
http://hpaste.org/55980

I cannot test it as I don't have an interpreter at hand, but if someone
has, I'd be glad to have comments.
(It might be more readable by using the State monad)

2012/1/2 max <mk at mtw.ru>

> В Mon, 2 Jan 2012 10:45:18 +0100
> Yves Parès <limestrael at gmail.com> пишет:
>
> Prelude> lines "string1\nstring2\r\nstring3\nstring4"
> ["string1","string2\r","string3","string4"]
>
> > Doesn't the function "lines" handle different line-endings?
> > (In the Prelude and in Data.List)
> >
> > If not, doing this with parsec would be easy (yet maybe slightly
> > overkill...)
> >
> >
> > 2012/1/2 max <mk at mtw.ru>
> >
> > > I want to write a function whose behavior is as follows:
> > >
> > > foo "string1\nstring2\r\nstring3\nstring4" = ["string1",
> > > "string2\r\nstring3", "string4"]
> > >
> > > Note the sequence "\r\n", which is ignored. How can I do this?
> > >
> > > _______________________________________________
> > > Haskell-Cafe mailing list
> > > Haskell-Cafe at haskell.org
> > > http://www.haskell.org/mailman/listinfo/haskell-cafe
> > >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120102/e58ab759/attachment.htm>


More information about the Haskell-Cafe mailing list