On Tuesday 25 May 2010 08:14:13, Ivan Miljenovic wrote:
> On 25 May 2010 16:12, Magicloud Magiclouds
>
> <magicloud.magiclo...@gmail.com> wrote:
> > Yes, this code works with a little hack. Thank you.
>
> I'm scared to ask: what pray tell is this little hack?

Looking at it again, probably making it work at all, because I never 
consumed the "Log for " lines, so produced an infinite list of empty lists 
:-/

Something like

separateOutput :: String -> [[String]]
separateOutput file =
    let contents = dropWhile (not . ("Log for " `isPrefixOf`)) $ lines file
        split [] = ([],[])
        split (h:tl) = let (lg,rst) = break ("Log for " `isPrefixOf`) tl 
                       in (h:lg,rst)
        msplit [] = Nothing
        msplit lns = Just (split lns)
    in unfoldr msplit contents

which really works :)
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to