[Haskell-cafe] cutting long strings into lines
Matthias Fischmann
fis at wiwi.hu-berlin.de
Sat Sep 30 16:53:25 EDT 2006
On Sat, Sep 30, 2006 at 08:51:40PM +0200, Udo Stenzel wrote:
> To: Matthias Fischmann <fis at wiwi.hu-berlin.de>
> Cc: haskell-cafe at haskell.org
> From: Udo Stenzel <u.stenzel at web.de>
> Date: Sat, 30 Sep 2006 20:51:40 +0200
> Subject: Re: [Haskell-cafe] cutting long strings into lines
>
> Matthias Fischmann wrote:
> > although this wasn't the original problem, i like it, too :). but now
> > i am stuck in finding an optimal implementation for lines.
>
> Isn't the obvious one good enough?
>
> lines [] = []
> lines s = go s
> where
> go [] = [[]]
> go ('\n':s) = [] : lines s
> go (c:s) = let (l:ls) = go s in (c:l):ls
thanks. good enough, yes. just not obvious to me... (-:
matthias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20060930/6b8ed2bb/attachment.bin
More information about the Haskell-Cafe
mailing list